关于JAVA读取TXT文件的问题!
如何判断是否已经读取到某个TXT文件的结尾呢?!
------解决方案--------------------read 出來為null
------解决方案--------------------String fileName = "test.txt ";
String record = null;
int reccount = 0;
try {
FileReader fr = new FileReader(fileName);
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
reccount++;
System.out.println(reccount + ": " + record);
}
br.close();
fr.close();
} catch (
IOException e) {
System.out.println( "Read file error! ");
e.printStackTrace();
}