ObjectInputStream.readObject

ObjectInputStream.readObject

Class Overview | Class Members | This Package | All Packages

Syntax
public final Object readObject() throws OptionalDataException, ClassNotFoundException, IOException
Description
Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overriden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completly restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they are individually restored. Exceptions are thrown for problems with the InputStream and for classes that should not be deserialized. All exceptions are fatal to the InputStream and leave it in an indeterminate state; it is up to the caller to ignore or recover the stream state.

Exceptions
ClassNotFoundException Class of a serialized object cannot be found.
Exceptions
InvalidClassException Something is wrong with a class used by serialization.
Exceptions
StreamCorruptedException Control information in the stream is inconsistent.
Exceptions
OptionalDataException Primitive data was found in the stream instead of objects.
Exceptions
IOException Any of the usual Input/Output related exceptions.