File file = new File("C:\\Users\\Administrator\\Desktop\\test.txt");
FileReader f = new FileReader(file);
BufferedReader bf = new BufferedReader(f);
String s ;
while ((s=bf.readLine())!=null) {
System.out.println(s);
}
不用while的判断只会输出一行。
原文:https://www.cnblogs.com/qiannianguyao/p/11997909.html