Java---读取大文件并及时
2021-06-09 00:05
标签:line class color 文件 pre except reader 读取 ack Java---读取大文件并及时 标签:line class color 文件 pre except reader 读取 ack 原文地址:https://www.cnblogs.com/shunguo/p/14501878.htmlpackage Demo;
import java.util.*;
import java.io.*;
//import org.apache.*;
import org.apache.commons.io.FileUtils;
public class loop {
public static void loopfile (File file){
try{
long start = System.currentTimeMillis();
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line;
while (( line = br.readLine()) != null){
System.out.println(line);
}
br.close();
long end = System.currentTimeMillis();
long diff = (end - start)/1000;
System.out.println("循环耗时: " + diff);
}catch (Exception e){
e.printStackTrace();
System.out.println(e);
}
}
public static void main(String[] args){
File file = new File("C:\\work_data\\Script&Tool\\RAW_DATA\\Data\\Site1.txt");
loop.loopfile(file);
}
}
上一篇:JavaDoc生成文档