| java.lang.Object | ||
| ↳ | java.io.InputStream | |
| ↳ | java.io.ObjectInputStream | |
An ObjectInputStream can be used to load Java objects from a stream where the objects were saved using an ObjectOutputStream. Primitive data (ints, bytes, chars, etc) can also be loaded if the data was saved as primitive types as well. It is invalid to attempt to read an object as primitive data.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ObjectInputStream.GetField | Inner class to provide access to serializable fields | ||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.io.ObjectStreamConstants
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new ObjectInputStream on the InputStream
input. | |||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new ObjectInputStream.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns the number of bytes of primitive data available from the
receiver.
| |||||||||||
Close this ObjectInputStream.
| |||||||||||
Default method to read objects from the receiver.
| |||||||||||
Reads at most
length bytes from the receiver and stores
them in byte array buffer starting at offset
offset. | |||||||||||
Reads a single byte from the receiver and returns the result as an int.
| |||||||||||
Reads and returns primitive data of type boolean read from the receiver
| |||||||||||
Reads and returns primitive data of type byte read from the receiver
| |||||||||||
Reads and returns primitive data of type char read from the receiver
| |||||||||||
Reads and returns primitive data of type double read from the receiver
| |||||||||||
Reads the fields of the object being read from the stream.
| |||||||||||
Reads and returns primitive data of type float read from the receiver
| |||||||||||
Reads bytes from the receiver into the byte array
buffer. | |||||||||||
Reads bytes from the receiver into the byte array
buffer. | |||||||||||
Reads and returns primitive data of type int read from the receiver
| |||||||||||
This method is deprecated.
Use BufferedReader
| |||||||||||
Reads and returns primitive data of type long read from the receiver
| |||||||||||
Read the next object from the receiver's underlying stream.
| |||||||||||
Reads and returns primitive data of type short from the receiver
| |||||||||||
Reads and returns primitive data of type String read in UTF format from
the receiver
| |||||||||||
Read the next unshared object from the receiver's underlying stream.
| |||||||||||
Reads and returns primitive data of type byte (unsigned) from the
receiver
| |||||||||||
Reads and returns primitive data of type short (unsigned) from the
receiver
| |||||||||||
Register object validator
object to be executed to perform
validation of objects loaded from the receiver. | |||||||||||
Skips
length bytes of primitive data from the receiver. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Enables/disables object replacement for the receiver.
| |||||||||||
Reads a new class descriptor from the receiver.
| |||||||||||
Method to be overriden by subclasses to read the next object from the
receiver's underlying stream.
| |||||||||||
Reads and validates the ObjectInputStream header from the receiver
| |||||||||||
Loads the Java class corresponding to the class descriptor
osClass(ObjectStreamClass) just read from the receiver. | |||||||||||
If
enableResolveObject() was activated, computes the
replacement object for the original object object and
returns the replacement. | |||||||||||
Retrieves the proxy class corresponding to the interface names.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.InputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.io.DataInput
| |||||||||||
From interface java.io.ObjectInput
| |||||||||||
Constructs a new ObjectInputStream on the InputStream input.
All reads are now filtered through this stream.
| input | The non-null InputStream to filter reads on. |
|---|
| IOException | If an IO exception happened when reading the stream header. |
|---|---|
| StreamCorruptedException | If the underlying stream does not contain serialized objects that can be read. |
Constructs a new ObjectInputStream. The representation and proper initialization is on the hands of subclasses.
| IOException | If not called from a subclass |
|---|---|
| SecurityException | If subclasses are not allowed |
Returns the number of bytes of primitive data available from the receiver. It should not be used at any arbitrary position; just when reading primitive data types (ints, chars, etc).
| IOException | If any IO problem occurred when trying to compute the bytes available. |
|---|
Close this ObjectInputStream. This implementation closes the target stream.
| IOException | If an error occurs attempting to close this stream. |
|---|
Default method to read objects from the receiver. Fields defined in the object's class and super classes (which are Serializable) will be read.
| IOException | If an IO error occurs attempting to read the object data |
|---|---|
| ClassNotFoundException | If the class of the object cannot be found |
| NotActiveException | If this method is not called from readObject() |
Reads at most length bytes from the receiver and stores
them in byte array buffer starting at offset
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
| buffer | the byte array in which to store the read bytes. |
|---|---|
| offset | the offset in buffer to store the read bytes. |
| length | the maximum number of bytes to store in buffer. |
| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads a single byte from the receiver and returns the result as an int. The low-order byte is returned or -1 of the end of stream was encountered.
| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type boolean read from the receiver
ObjectOutputStream.writeBoolean()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type byte read from the receiver
ObjectOutputStream.writeByte()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type char read from the receiver
ObjectOutputStream.writeChar()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type double read from the receiver
ObjectOutputStream.writeDouble()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads the fields of the object being read from the stream. The stream
will use the currently active getField object, allowing
users to load emulated fields, for cross-loading compatibility when a
class definition changes.
| IOException | If an IO exception happened |
|---|---|
| ClassNotFoundException | If a class of an object being de-serialized can not be found |
| NotActiveException | If there is no object currently being loaded (invalid to call this method) |
Reads and returns primitive data of type float read from the receiver
ObjectOutputStream.writeFloat()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads bytes from the receiver into the byte array buffer.
This method will block until length number of bytes have
been read.
| buffer | the byte array in which to store the read bytes. |
|---|---|
| offset | the offset in buffer to store the read bytes. |
| length | the maximum number of bytes to store in buffer. |
| IOException | if a problem occurs reading from this stream. |
|---|
Reads bytes from the receiver into the byte array buffer.
This method will block until buffer.length number of bytes
have been read.
| buffer | the buffer to read bytes into |
|---|
| IOException | if a problem occurs reading from this stream. |
|---|
Reads and returns primitive data of type int read from the receiver
ObjectOutputStream.writeInt()| IOException | If an IO exception happened when reading the primitive data. |
|---|
This method is deprecated.Use BufferedReader
Reads and returns the next line (primitive data of type String) read from the receiver
ObjectOutputStream.writeLine()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type long read from the receiver
ObjectOutputStream.writeLong()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Read the next object from the receiver's underlying stream.
| IOException | If an IO exception happened when reading the object |
|---|---|
| ClassNotFoundException | If the class of one of the objects in the object graph could not be found |
| OptionalDataException | If primitive data types were found instead of an object. |
Reads and returns primitive data of type short from the receiver
ObjectOutputStream.writeShort()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type String read in UTF format from the receiver
ObjectOutputStream.writeUTF()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Read the next unshared object from the receiver's underlying stream.
| IOException | If an IO exception happened when reading the object |
|---|---|
| ClassNotFoundException | If the class of one of the objects in the object graph could not be found |
Reads and returns primitive data of type byte (unsigned) from the receiver
ObjectOutputStream.writeUnsignedByte()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Reads and returns primitive data of type short (unsigned) from the receiver
ObjectOutputStream.writeUnsignedShort()| IOException | If an IO exception happened when reading the primitive data. |
|---|
Register object validator object to be executed to perform
validation of objects loaded from the receiver. Validations will be run
in order of decreasing priority, defined by priority.
| object | An ObjectInputValidation to validate objects loaded. |
|---|---|
| priority | validator priority |
| NotActiveException | If this method is not called from readObject() |
|---|---|
| InvalidObjectException | If object is null.
|
Skips length bytes of primitive data from the receiver. It
should not be used to skip bytes at any arbitrary position; just when
reading primitive data types (ints, chars, etc).
| length | How many bytes to skip |
|---|
| IOException | If any IO problem occurred when trying to skip the bytes. |
|---|
Enables/disables object replacement for the receiver. By default this is not enabled. Only trusted subclasses (loaded with system class loader) can override this behavior.
| enable | if true, enables replacement. If false, disables replacement. |
|---|
| SecurityException | If the class of the receiver is not trusted |
|---|
Reads a new class descriptor from the receiver. Return the class descriptor read.
ObjectStreamClass read from the stream.| IOException | If an IO exception happened when reading the class descriptor. |
|---|---|
| ClassNotFoundException | If a class for one of the objects could not be found |
Method to be overriden by subclasses to read the next object from the receiver's underlying stream.
| IOException | If an IO exception happened when reading the object |
|---|---|
| ClassNotFoundException | If the class of one of the objects in the object graph could not be found |
| OptionalDataException | If primitive data types were found instead of an object. |
Reads and validates the ObjectInputStream header from the receiver
| IOException | If an IO exception happened when reading the stream header. |
|---|---|
| StreamCorruptedException | If the underlying stream does not contain serialized objects that can be read. |
Loads the Java class corresponding to the class descriptor
osClass(ObjectStreamClass) just read from the receiver.
| osClass | An ObjectStreamClass read from the receiver. |
|---|
| IOException | If any IO problem occurred when trying to load the class. |
|---|---|
| ClassNotFoundException | If the corresponding class cannot be found. |
If enableResolveObject() was activated, computes the
replacement object for the original object object and
returns the replacement. Otherwise returns object.
| object | Original object for which a replacement may be defined |
|---|
object| IOException | If any IO problem occurred when trying to resolve the object. |
|---|
Retrieves the proxy class corresponding to the interface names.
| interfaceNames | The interfaces used to create the proxy class |
|---|
| IOException | If any IO problem occurred when trying to load the class. |
|---|---|
| ClassNotFoundException | If the proxy class cannot be created |