I am using ObjectOutputStream
to write the data into a file. Following is the code snippet.
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f)))
{
oos.writeObject(allObjects);
}
Questions:
The problem being I saw once the file was corrupted and while debugging I had the above mentioned queries.
No: Closing ObjectOutputStream will automatically close FileOutputStream
No: The stream will be flushed automatically on close.