Serialization Section Index
Where can I learn (more) about Java's support asynchronous and publish/subscribe messaging using JMS (Java Message Service)?
Check out the jGuru JMS FAQ.
Where can I learn (more) about Java's I/O (input/output, IO) capabilities?
Check out the jGuru IO FAQ.
What is the easiest way to convert my java beans into xml?
Use java.beans.XMLEncoder.
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml")));
e.writeObject(new JButton("Hello...more
How can i implement Serializable with my own Custom Data Format?
import java.io.*;
public class CustomDataExample implements Serializable {
transient int dimension;
transient int thearray[][];
/**
* Create the triangular array of dimension d...more
What's the serialver syntax to get the serialVersionUID of an array?
You need to pass in the array "type" after the [ character, and before a ; character. If the type is a class, add the letter L and the fully qualified class name. If the type is a primitive, the t...more
What does the Serializable interface do?
Serializable is a tagging interface; it prescribes no methods.
It serves to assign the Serializable data type to
the tagged class and to identify the class as one which the
developer has designed ...more
Where can I learn (more) about Java RMI (Remote Method Invocation)?
Check out the jGuru RMI FAQ.
How can I serialize a JavaMail Message?
You can't. As messages are associated with folders which are associated with sessions, Message objects are considered not serializable. Like threads and images you need to save the pieces that are...more
What is the correct order of ObjectInputStream ObjectOutputStream creation on the client and the server when sending objects over a network connection?
According to the API documentation for ObjectInputStream's
constructor:
The stream header containing the magic number and version number are read from the stream and verified. This method will b...more
How can I instantiate a serialized JavaBean into an applet if my .ser file is in jar or zip archive?
The Beans.instantiate() method needs to be passed the proper classloader. Just passing in null is not sufficient for an applet. For instance, if your class was Foo.class, use the following:
Beans....more
What is the role of serialization in EJB?
A big part of EJB is that it is a framework for underlying RMI: remote method invocation. You're invoking methods remotely from JVM space 'A' on objects which are in JVM space 'B' -- possibly run...more
How can I determine the byte length of an object that I serialize to a stream?
There are a couple of things you can do.
First, you can pipe the ObjectOutputStream into a ByteArrayOutputStream, then examine the
length of the byte array:
ByteArrayOutputStream baos = new Byte...more
Are there any limits on the size of a serialized object?
There are limits, but in practice you shouldn't encounter them.
You are limited by the amount of memory your JVM can allocate to the creation and maintainence of your object. As for writing it ou...more
Are classes that implement Serializable required to have no-argument constructors?
No. This is a common misconception.
The deserialization process does not use the object's
constructor - the object is instantiated without a constructor
and initialized using the serialized inst...more
What's the difference between the SUID (Stream Unique IDentifier) and the private static member serialVersionUID?
The SUID is one of a number of things that the serialization
protocol writes to the stream in addition to the serialized
object (other things include a magic number and the fully-
qualified class...more