Content received from: http://JavaFAQ.nu/java-article121.html


I write my data into a file with serialization methods (Java 1.1.8). How can I r
Monday, May 05, 2003 (00:00:00)

Posted by jalex

Question: I write my data into a file with serialization methods (Java 1.1.Cool. How can I read this file back with serialization methods in Java 1.2.2? I have compatibility exceptions!

Answer: Java has two serialization protocols.
Keep in mind that:
JDK 1.1.x write using PROTOCOL_VERSION_1 (default)
JDK 1.2.x write using PROTOCOL_VERSION_2 (default)
JDK 1.1.7 and higher can read both protocols

As you see with JDK 1.1.7 you can read/write with both protocol versions. You just need to synchronize them.

If you use JDK 1.2 and higher you can override the default protocol version by using:

ObjectInputStream.useProtocolVersion(PROTOCOL_VERSION_1)

Usage PROTOCOL_VERSION_1 provides compatibility with all Java
versions.

***************************************
Our older tips: March 22, 2001 - October 21, 2002 read here.
All published and not published on site tips you can find here