| java.lang.Object | ||
| ↳ | java.io.OutputStream | |
| ↳ | java.io.ObjectOutputStream | |
An ObjectOutputStream can be used to save Java objects into a stream where the objects can be loaded later with an ObjectInputStream. Primitive data (ints, bytes, chars, etc) can also be saved.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ObjectOutputStream.PutField | Inner class to provide access to serializable fields | ||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.io.ObjectStreamConstants
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new ObjectOutputStream on the OutputStream
output. | |||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
ObjectOutputStream. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Close this ObjectOutputStream.
| |||||||||||
Default method to write objects into the receiver.
| |||||||||||
Flush this ObjectOutputStream.
| |||||||||||
Return the
PutField object for the receiver. | |||||||||||
Reset the receiver.
| |||||||||||
Set the receiver to use the given protocol version.
| |||||||||||
Writes
length bytes from the byte array
buffer starting at offset offset to the
ObjectOutputStream. | |||||||||||
Write one byte (
value) into the receiver's underlying
stream. | |||||||||||
Writes the entire contents of the byte array
buffer to
this ObjectOutputStream. | |||||||||||
Write primitive data of type boolean (
value)into the
receiver's underlying stream. | |||||||||||
Write primitive data of type byte (
value)into the
receiver's underlying stream. | |||||||||||
Write a String as a sequence of bytes (only lower-order 8 bits of each
char are written), as primitive data (
value) into the
receiver's underlying stream. | |||||||||||
Write primitive data of type char (
value)into the
receiver's underlying stream. | |||||||||||
Write a String as a sequence of char, as primitive data (
value)
into the receiver's underlying stream. | |||||||||||
Write primitive data of type double (
value)into the
receiver's underlying stream. | |||||||||||
Write the fields of the object being dumped.
| |||||||||||
Write primitive data of type float (
value)into the
receiver's underlying stream. | |||||||||||
Write primitive data of type int (
value)into the
receiver's underlying stream. | |||||||||||
Write primitive data of type long (
value)into the
receiver's underlying stream. | |||||||||||
Write object
object into the receiver's underlying stream. | |||||||||||
Write primitive data of type short (
value)into the
receiver's underlying stream. | |||||||||||
Write primitive data of type String (
value) in UTF
format into the receiver's underlying stream. | |||||||||||
Write object
object into the receiver's underlying stream
unshared with previously written identical objects. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Writes optional information for class
aClass into the
stream represented by the receiver. | |||||||||||
Writes optional information for a proxy class into the stream represented
by the receiver.
| |||||||||||
Flushes buffered primitive data into the receiver.
| |||||||||||
Enables/disables object replacement for the receiver.
| |||||||||||
If
enableReplaceObject() was activated, computes the
replacement object for the original object object and
returns the replacement. | |||||||||||
Write class descriptor
classDesc into the receiver. | |||||||||||
Method to be overridden by subclasses to write
object into
the receiver's underlying stream. | |||||||||||
Writes the ObjectOutputStream header into the underlying stream.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.OutputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.io.DataOutput
| |||||||||||
From interface java.io.Flushable
| |||||||||||
From interface java.io.ObjectOutput
| |||||||||||
Constructs a new ObjectOutputStream on the OutputStream
output. All writes are now filtered through this stream.
| output | The non-null OutputStream to filter writes on. |
|---|
| IOException | If an IO exception happened when writing the object stream header |
|---|
Constructs a new ObjectOutputStream. The representation
and proper initialization is in the hands of subclasses.
| IOException | |
| SecurityException | if subclassing this is not allowed |
| IOException |
Close this ObjectOutputStream. Any buffered data is flushed. This implementation closes the target stream.
| IOException | If an error occurs attempting to close this stream. |
|---|
Default method to write objects into the receiver. Fields defined in the object's class and superclasses (which are Serializable) will be saved.
| IOException | If an IO error occurs attempting to write the object data |
|---|
Flush this ObjectOutputStream. Any pending writes to the underlying stream are written out when this method is invoked.
| IOException | If an error occurs attempting to flush this ObjectOutputStream. |
|---|
Return the PutField object for the receiver. This allows
users to transfer values from actual object fields in the object being
dumped to the emulated fields represented by the PutField
returned by this method.
| IOException | If an IO error occurs |
|---|---|
| NotActiveException | If this method is not called from writeObject() |
Reset the receiver. A marker is written to the stream, so that deserialization will also perform a rest at the same point. Objects previously written are no longer remembered, so they will be written again (instead of a cyclical reference) if found in the object graph.
| IOException | If any IO problem occurred when trying to reset the receiver |
|---|
Set the receiver to use the given protocol version.
| version | protocol version to be used |
|---|
| IOException | If an IO error occurs |
|---|
Writes length bytes from the byte array
buffer starting at offset offset to the
ObjectOutputStream.
| buffer | the buffer to be written |
|---|---|
| offset | offset in buffer to get bytes |
| length | number of bytes in buffer to write |
| IOException | If an error occurs attempting to write to this OutputStream. |
|---|
Write one byte (value) into the receiver's underlying
stream.
| value | The primitive data to write. Only the lower byte is written. |
|---|
| IOException | If an IO exception happened when writing the byte. |
|---|
Writes the entire contents of the byte array buffer to
this ObjectOutputStream.
| buffer | the buffer to be written |
|---|
| IOException | If an error occurs attempting to write to this ObjectOutputStream. |
|---|
Write primitive data of type boolean (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type byte (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write a String as a sequence of bytes (only lower-order 8 bits of each
char are written), as primitive data (value) into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type char (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write a String as a sequence of char, as primitive data (value)
into the receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type double (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write the fields of the object being dumped. The stream will use the
currently active PutField object, allowing users to dump
emulated fields, for cross-loading compatibility when a class definition
changes.
| IOException | If an IO error occurs |
|---|
Write primitive data of type float (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type int (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type long (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write object object into the receiver's underlying stream.
| object | The object to write |
|---|
| IOException | If an IO exception happened when writing the object |
|---|
Write primitive data of type short (value)into the
receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write primitive data of type String (value) in UTF
format into the receiver's underlying stream.
| value | The primitive data to write |
|---|
| IOException | If an IO exception happened when writing the primitive data. |
|---|
Write object object into the receiver's underlying stream
unshared with previously written identical objects.
| object | The object to write |
|---|
| IOException | If an IO exception happened when writing the object |
|---|
Writes optional information for class aClass into the
stream represented by the receiver. This optional data can be read when
deserializing the class descriptor (ObjectStreamClass) for this class
from the input stream. By default no extra data is saved.
| aClass | The class to annotate |
|---|
| IOException | If an IO exception happened when annotating the class. |
|---|
Writes optional information for a proxy class into the stream represented by the receiver. This optional data can be read when deserializing the proxy class from the input stream. By default no extra data is saved.
| aClass | The proxy class to annotate |
|---|
| IOException | If an IO exception happened when annotating the class. |
|---|
Flushes buffered primitive data into the receiver.
| IOException | If an error occurs attempting to drain the data |
|---|
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 |
|---|
If enableReplaceObject() 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. |
|---|
Write class descriptor classDesc into the receiver.
| classDesc | The ObjectStreamClass object to dump |
|---|
| IOException | If an IO exception happened when writing the class descriptor. |
|---|
Method to be overridden by subclasses to write object into
the receiver's underlying stream.
| object | the object |
|---|
| IOException | If an IO exception happened when writing the object |
|---|
Writes the ObjectOutputStream header into the underlying stream.
| IOException | If an IO exception happened when writing the stream header. |
|---|