8.8 Object serialization



Object serialization is to take any object that implements the Serializable interface and turn it into a sequence of bytes that can later be restored fully into the original object.

Object serialization allows you to implement lightweight persistence.

Object serialization was added to the language to support two major features: Remote mothod invocation(RMI) and Java Beans.

To serialize an object, you create some sort of OutputStream object and then wrap it insied an ObjectOutputStream object.  Then you can writeObject() to the stream.  To reverse the process, you wrap an InputStream inside an ObjectInputStream and call readObject().

Case Study: Worm.java


Next Page