Using the Externalizable Interface

The java.io.Externalizable interface can be used when an object must have complete control over how the object is serialized or externalized to be consistent with the interface name. The two methods that must be implemented are readExtenal and writeExternal. The method signatures are in Listing 22.10.

Code Listing 22.10. Method Signatures for the java.io.Externalizable Interface
public void readExternal(ObjectInputin)
                  throws IOException,
                         ClassNotFoundException;

public void writeExternal(ObjectOutputout)
                   throws IOException;

The Externalizable interface supercedes the Serializable interface. If a class implements both the Externalizable and Serializable interface, the Externalizable will be used over the Serializable ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.