【发布时间】:2013-07-04 18:58:11
【问题描述】:
我正在制作日志,我想读取 log.txt 文件的最后一行,但在读取最后一行后我无法让 BufferedReader 停止。
这是我的代码:
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("C:\\testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
【问题讨论】:
-
IMO,这不是一个重复的问题。
标签: java io bufferedreader