I am using ObjectOutputStream to create a file of serialized objects. I then use an ObjectInputStream to with the readObject() method to get the objects back out of the file.
It works great the first time. Meaning that if the file does not exist and I open it then append any number of objects, I can open the ObjectInputStream object and access all the objects.
However, if I subsequently open the same file (using the append option) and add more objects, the ObjectInputStream object gets a java.io.StreamCorruptedException: "invalid type code: AC" error where the new objects should start.
Has anyone else run into this? I even went back to some basic textbook examples from the Deitel book and still get the same error.
Edit: I found this - You may not append to the end of a serialized stream once it has been closed and reopened in append mode. The writes will appear to work, but when you go to read the file later you will get a java.io.StreamCorruptedException. at "http://mindprod.com/jgloss/gotchas.html#SERIALIZATION"