Object Streams

When Sun added Remote Method Invocation (RMI) to Java, it also added the capability to stream arbitrary objects. The ObjectInput and ObjectOutput interfaces define methods for reading and writing any object, in the same way that DataInput and DataOutput define methods for reading and writing primitive types. In fact, the ObjectInput and ObjectOutput interfaces extend the DataInput and DataOutput interfaces, respectively. The ObjectInput interface adds a single input method for reading in an object:

public abstract Object readObject()
throws ClassNotFoundException, IOException

Similarly, the ObjectOutput interface adds a single output method:

public abstract void writeObject(Object obj)
throws IOException

The two interfaces ...

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.