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
什麼是*實際*問題?這是否是一種「正確」的方式?它會工作 - 但你會輸出一些數據到控制檯。 –