读取txt文件乱码
BufferedReader read = new BufferedReader(new FileReader(new File(filename)));
解决办法:
InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "UTF-8");
BufferedReader read = new BufferedReader(isr);
因为InputStreamReader和BufferedReader 都继承自Reader,而BufferedReader 的构造器又是Reader.
Writer也是一样的处理
FileOutputStream writerStream = new FileOutputStream(filePath, true);
BufferedWriter oWriter = new BufferedWriter(new OutputStreamWriter(writerStream, "UTF-8"));
该贴被shellyC1314编辑于2015-8-14 9:17:17