import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class TestFileWriter {
public static void main(String [] args) {
try {
FileReader out = new FileReader("d:/a.txt");
BufferedReader br=new BufferedReader(out);
char a[]=new char[1024];
String line=null;
for(;(line=br.readLine())!=null;){
System.out.print(new String(line.getBytes("UTF-8"))+"\n");//inputStreamReader中有解码器,而Filereader是其子类,没有继承里面的这个方法,所以转码时出错。要么直接用父类进行流的操作。
}
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java io 读取文件乱码及读取不出来的问题,布布扣,bubuko.com
原文地址:http://7122819.blog.51cto.com/7112819/1538639