Is it not possible to append to an ObjectOutputStream
?
I am trying to append to a list of objects. Following snippet is a function that is called whenev
As the API says, the ObjectOutputStream
constructor writes the serialization stream header to the underlying stream. And this header is expected to be only once, in the beginning of the file. So calling
new ObjectOutputStream(fos);
multiple times on the FileOutputStream
that refers to the same file will write the header multiple times and corrupt the file.