Friday, May 29, 2009

Externalizable interface

The Externalizable interface allows a programmer to have a complete control over the serialization and deserialization processes.

The Externalizable interface has the following two methods:

  • public void writeExternal(ObjectOutput objout): This method is used to save the contents of an object by calling the methods of the DataOutput interface for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, arrays, etc.


  • public void readExternal(ObjectInput objin): This method is used to restore the contents of an object that was saved using the writeExternal() method. It calls the methods of the DataInput interface for primitive types and the readObject() method for objects, strings, arrays, etc.

No comments:

Post a Comment