Serializable Java Help

Serializable

Only an object that implements the Serializable interface can be saved and restored by the serialization facilities. The Serializable interface defines’no members. It is simply used to indicate that a class may be serialized. If.a class is serializable, all of its subclasses are also serializable

Externalizable

The lava facilities for serialization and deserialization have been designed so that much of the work to save and restore the state of an object occurs automatically. However, there are cases in which the programmer may need to have control over these processes. For example, it may be desirable to use compression or encryption techniques. The Externalizable interface is designed for these situations.  The Externalizable interface defines these two methods

In these methods, inStream is the byte stream from which the object is to be read, and outstream  is the byte stream to which the object IS to be written

ObjectOutput 

The ObjectOutput interface extends the DataOutput interface and supports object serialization. Note especially the writeObject( ) method. This is called to serialize an object. All of these methods will throw an IOException on error conditions.

ObjectOutputStream

The ObjectOutputStream class extends the OutputStream class and implements the Object Output interface. Jt is responsible for writing objects to a stream. The constructor of this class

The argument outStr cnn/ is the output stream to which serialized objects will be written .The most commonly used methods in this class are shown. They will throw an IOException on error conditions java 2 adds an inner class to ObjectOutputStream called PutField. It facilitates the writing of persistent fields and its use is beyond the scope of this book.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 18, 2014 in Input/output: Exploring java.io

Share the Story

About the Author

Back to Top