Then an ObjectInputStream is created that reads from the InputStream . Generally, objects are read with the readObject method and primitives are read from the stream with the methods of DataInput . The readObject method deserializes the next object in the stream and traverses its references to other objects recursively to create the complete graph of objects serialized. Primitive data types are read from the stream with the methods in the DataOutput interface, such as readInt , readFloat , or readUTF . Individual bytes and arrays of bytes are read with the methods of InputStream .
All primitive data is read from block-data records.
ObjectInputStream can be extended to utilize customized information in the stream about classes or to replace objects that have been deserialized. Refer to the resolveClass and resolveObject method descriptions for details. Object Streams as Containers Object Serialization produces and consumes a stream of bytes that contain one or more primitives and objects. The objects written to the stream, in turn, refer to other objects which are also represented in the stream. Object Serialization produces just one stream format that encodes and stores the contained objects.