It is the stream that is corrupted, not the ObjectOutputStream
. That is the name of a class.
This problem arises when you try to read the result of multiple ObjectOutputStreams
with a single ObjectInputStream
. It isn't valid. ObjectOutputStream
writes a header which starts with - guess what? 0xAC. So when you use a single ObjectInputStream
to read a stream that has been created by multiple ObjectOutputStreams
, it finds an unexpected 0xAC and throws that exception.
Solution: don't do that. You can't append multiple ObjectOutputStreams
to a file, and you can't use multiple ObjectOutputStreams
over a socket unless you have extraordinary co-ordination sufficient to create a new ObjectInputStream
at the precise point in the stream where the last ObjectOutputStream
left off: instead, you must use the same ObjectInputStream
and ObjectOutputStream
for the life of the socket.