I have a file which is comprised of one serialized String object written to the start of the file followed by the raw bytes of the file I am attempting to extract.
Here is my code:
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();
The code takes an unusable long time for large files (1.5 GB, for example). How can I speed up the code? Am I using the wrong classes?
Regards.