1
如何读取一个TB大小的两个日志文件,而不会耗尽我的机器上的内存。我会对它们进行一些比较。我想要做的这在Java.Would下面的代码工作吗?我担心的是,FileStream将无法保存日志文件的数据。从日志文件中读取一个TB的数据
public static void main(String args[])
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("textfile.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}
catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
任何人都可以指导我这样做的正确方法。
您是否试过该代码?这是功课吗? – hatchet
运行它,让我们知道它是如何去。如果/当它失败*然后*适当的问一个关于它的问题。 – Crisfole
什么是*实际*问题?这是否是一种“正确”的方式?它会工作 - 但你会输出一些数据到控制台。 –