This content has been marked as final. Show 3 replies
We do not close the FileInputStream and FileOutputStream. Is there a risk of doing so?Not really. The object streams extend the Filter streams, and their close() methods are defined to flush and close their source/target streams. I've never seen it cause a problem.
On the other hand closing first an underlying stream would lead to the loss of eventual buffers maintained by the streams above.
But if we close FileInputStream after ObjectInputStream, and FileOutputStream after ObjectOutputStream I think there is no problem, isn't it?