我有一個文件,它由一個寫入文件開頭的序列化String對象組成,後面跟着我試圖提取的文件的原始字節。使用BufferedOutputStream創建大文件需要很長時間
這裏是我的代碼:
FileInputStream fileInputStream = new FileInputStream("C:\Test.tst");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
String string = (String) objectInputStream.readObject();
FileOutputStream fileOutputStream = new FileOutputStream("C:\ExtractedTest.tst");
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
while(fileInputStream.available())
{
int i = fileInputStream.read();
bufferedOutputStream.write(i);
}
bufferedOutputStream.close();
fileOutputStream.close();
的代碼將不可用很長一段時間對於大文件(1.5 GB,例如)。我如何加快代碼?我使用錯誤的類嗎?
問候。
定義'不可用的長time' - 你期待什麼時候? – reto
與通過'mkfile'創建文件相比,這需要很長時間嗎? –