I am able to write an object using ObjectOutputStream but when I try to read the object back using ObjectInputStream I get a StreamCorruptedException. How can I overcome this?
- If the stream header is invalid.
- If control information not found.
- If control information is invalid.
- JDK 1.1.5 or less attempts to call readExternal() on a PROTOCOL_VERSION_2 stream.
One additional cause of StreamCorruptedException that is not explicitly mentioned in the specification is if you try to deserialize a String of length >64kB into a pre-version 1.3 JVM. Prior to Java version 1.3, serialization of String objects of this length was not supported.