字符流查看txt文件

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


public class Test03 {
public static void main(String[] args) throws FileNotFoundException {
FileReader fr=new FileReader("D:\\新建文件夹\\等待春天.txt");
char c[]=new char[1024];
int b =0;
try {
while((b=fr.read(c))!=-1){
String a=new String(c, 0, b);
System.out.println(a);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

posted @ 2016-02-19 13:08  有点小优雅  阅读(151)  评论(0编辑  收藏  举报