When trying to serialize large strings, or pass large strings as parameters to remote methods, I keep getting a java.io.EOFException. This only happens for trings, not for other large objects. What is the problem?

Tim Rohaly

In Java versions prior to 1.3, there is a limit of 64kB on the size of a serialized String object. This is because ObjectOutputStream delegates String serialization to an instance of DataOutputStream, which writes out the length of a string as a 16-bit short, followed by the UTF-8 encoded string. The 64kB limit is due to the maximum value a short datatype can hold. A UTFDataFormatException will be thrown if you try to serialize a String greater than 64kB in these versions of the JDK.

This restriction has been removed by implementation changes in Java 2 SDK versions 1.3 and later. If you attempt to deserialize a String larger than 64kB in a pre-1.3 JVM you will get a StreamCorruptedException.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact