Java

Java读取数据流的时候,一定要指定数据流的编码方式,否则将使用本地环境中的默认字符集。

BufferedReader reader = null;
String laststr = "";
try {
    Reader in = new InputStreamReader(new FileInputStream(path), "UTF-8");
    reader = new BufferedReader(in);
    String tempString = null;
    while ((tempString = reader.readLine()) != null) {
        laststr = laststr + tempString;
    }
    reader.close();
} catch (IOException e) {
    e.printStackTrace();
} finally {
    if (reader != null) {
        try {
            reader.close();
        } catch (IOException e1) {
	}
			}
    }
return laststr;
原文地址:https://www.cnblogs.com/kangping/p/7150157.html