日期:2014-05-20 浏览次数:20717 次
public static void main(String[] args) throws Exception {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
try {
File file = new File("c:/data.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String buf = null;
String str = null;
if (file.length() > 1024 * 1024 * 1024) {
br.skip(file.length() / 3 * 2);// 当文件超过1M大小的时候,跳过文本长度的2/3,具体跳过多少视实际情况而定,文件越大可以跳过的部分越多
}
while ((buf = br.readLine()) != null) {
str = buf;
}
br.close();
System.out.println(str);
} catch (Exception e) {
e.printStackTrace();
}
}
}, 0, 5000);
}