| java.lang.Object | ||
| ↳ | java.io.OutputStream | |
| ↳ | java.io.ObjectOutputStream | |
A specialized OutputStream that is able to write (serialize) Java objects as well as primitive data types (int, byte, char etc.). The data can later be loaded using an ObjectInputStream.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | ObjectOutputStream.PutField | PutField is an inner class to provide access to the persistent fields that are written to the target stream. | |||||||||
| [Expand] 
           Inherited Constants
           | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From interface java.io.ObjectStreamConstants | |||||||||||
| [Expand] 
           Inherited Fields
           | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From interface java.io.ObjectStreamConstants | |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Constructs a new ObjectOutputStream that writes to the OutputStream 
            output. | ||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Constructs a new 
            ObjectOutputStream. | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Closes this stream.
           | ||||||||||
|  | 
           Default method to write objects to this stream.
           | ||||||||||
|  | 
           Writes buffered data to the target stream and calls the 
            flushmethod of the target stream. | ||||||||||
|  | 
           Gets this stream's 
            PutFieldobject. | ||||||||||
|  | 
           Resets the state of this stream.
           | ||||||||||
|  | 
           Sets the specified protocol version to be used by this stream.
           | ||||||||||
|  | 
           Writes a single byte to the target stream.
           | ||||||||||
|  | 
           Writes 
            countbytes from the byte arraybufferstarting at offsetindexto the target stream. | ||||||||||
|  | 
           Writes a boolean to the target stream.
           | ||||||||||
|  | 
           Writes a byte (8 bit) to the target stream.
           | ||||||||||
|  | 
           Writes the string 
            valueas a sequence of bytes to the target stream. | ||||||||||
|  | 
           Writes a character (16 bit) to the target stream.
           | ||||||||||
|  | 
           Writes the string 
            valueas a sequence of characters to the target stream. | ||||||||||
|  | 
           Writes a double (64 bit) to the target stream.
           | ||||||||||
|  | 
           Writes the fields of the object currently being written to the target stream.
           | ||||||||||
|  | 
           Writes a float (32 bit) to the target stream.
           | ||||||||||
|  | 
           Writes an integer (32 bit) to the target stream.
           | ||||||||||
|  | 
           Writes a long (64 bit) to the target stream.
           | ||||||||||
|  | 
           Writes an object to the target stream.
           | ||||||||||
|  | 
           Writes a short (16 bit) to the target stream.
           | ||||||||||
|  | 
           Writes a string encoded with 
            modified UTF-8to the target stream. | ||||||||||
|  | 
           Writes an unshared object to the target stream.
           | ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Writes optional information for class 
            aClassto the output stream. | ||||||||||
|  | 
           Writes optional information for a proxy class to the target stream.
           | ||||||||||
|  | 
           Writes buffered data to the target stream.
           | ||||||||||
|  | 
           Enables object replacement for this stream.
           | ||||||||||
|  | 
           Allows trusted subclasses to substitute the specified original 
            objectwith a new object. | ||||||||||
|  | 
           Writes a class descriptor to the target stream.
           | ||||||||||
|  | 
           Method to be overridden by subclasses to write 
            objectto the target stream. | ||||||||||
|  | 
           Writes the 
            ObjectOutputStreamheader to the target 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 that writes to the OutputStream output.
| output | the non-null OutputStream to filter writes on. | 
|---|
| IOException | if an error occurs while writing the object stream header | 
|---|
Constructs a new ObjectOutputStream. This default constructor can be used by subclasses that do not want to use the public constructor if it allocates unneeded data.
| IOException | if an error occurs when creating this stream. | 
|---|
Closes this stream. Any buffered data is flushed. This implementation closes the target stream.
| IOException | if an error occurs while closing this stream. | 
|---|
Default method to write objects to this stream. Serializable fields defined in the object's class and superclasses are written to the output stream.
| IOException | if an error occurs while writing to the target stream. | 
|---|---|
| NotActiveException | if this method is not called from writeObject(). | 
Writes buffered data to the target stream and calls the flush method of the target stream.
| IOException | if an error occurs while writing to or flushing the output stream. | 
|---|
Gets this stream's PutField object. This object provides access to the persistent fields that are eventually written to the output stream. It is used to transfer the values from the fields of the object that is currently being written to the persistent fields.
| IOException | if an I/O error occurs. | 
|---|---|
| NotActiveException | if this method is not called from writeObject(). | 
Resets the state of this stream. A marker is written to the stream, so that the corresponding input stream will also perform a reset 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 reset()is called during the serialization of an object. | 
|---|
Sets the specified protocol version to be used by this stream.
| version | the protocol version to be used. Use a PROTOCOL_VERSION_xconstant fromjava.io.ObjectStreamConstants. | 
|---|
| IllegalArgumentException | if an invalid versionis specified. | 
|---|---|
| IOException | if an I/O error occurs. | 
Writes a single byte to the target stream. Only the least significant byte of the integer value is written to the stream. Blocks until the byte is actually written.
| value | the byte to write. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes count bytes from the byte array buffer starting at offset index to the target stream. Blocks until all bytes are written.
| buffer | the buffer to write. | 
|---|---|
| offset | the index of the first byte in bufferto write. | 
| length | the number of bytes from bufferto write to the output stream. | 
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a boolean to the target stream.
| value | the boolean value to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a byte (8 bit) to the target stream.
| value | the byte to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes the string value as a sequence of bytes to the target stream. Only the least significant byte of each character in the string is written.
| value | the string to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a character (16 bit) to the target stream.
| value | the character to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes the string value as a sequence of characters to the target stream.
| value | the string to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a double (64 bit) to the target stream.
| value | the double to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes the fields of the object currently being written to the target stream. The field values are buffered in the currently active PutField object, which can be accessed by calling putFields().
| IOException | if an error occurs while writing to the target stream. | 
|---|---|
| NotActiveException | if there are no fields to write to the target stream. | 
Writes a float (32 bit) to the target stream.
| value | the float to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes an integer (32 bit) to the target stream.
| value | the integer to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a long (64 bit) to the target stream.
| value | the long to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes an object to the target stream.
| object | the object to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a short (16 bit) to the target stream.
| value | the short to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes a string encoded with modified UTF-8 to the target stream.
| value | the string to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes an unshared object to the target stream. This method is identical to writeObject, except that it always writes a new object to the stream versus the use of back-referencing for identical objects by writeObject.
| object | the object to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes optional information for class aClass to the output stream. This optional data can be read when deserializing the class descriptor (ObjectStreamClass) for this class from an input stream. By default, no extra data is saved.
| aClass | the class to annotate. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes optional information for a proxy class to the target stream. This optional data can be read when deserializing the proxy class from an input stream. By default, no extra data is saved.
| aClass | the proxy class to annotate. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes buffered data to the target stream. This is similar to flush but the flush is not propagated to the target stream.
| IOException | if an error occurs while writing to the target stream. | 
|---|
Enables object replacement for this stream. By default this is not enabled. Only trusted subclasses (loaded with system class loader) are allowed to change this status.
| enable | trueto enable object replacement;falseto disable it. | 
|---|
Allows trusted subclasses to substitute the specified original object with a new object. Object substitution has to be activated first with calling enableReplaceObject(true). This implementation just returns object.
| object | the original object for which a replacement may be defined. | 
|---|
object.| IOException | if any I/O error occurs while creating the replacement object. | 
|---|
Writes a class descriptor to the target stream.
| classDesc | the class descriptor to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Method to be overridden by subclasses to write object to the target stream.
| object | the object to write to the target stream. | 
|---|
| IOException | if an error occurs while writing to the target stream. | 
|---|
Writes the ObjectOutputStream header to the target stream.
| IOException | if an error occurs while writing to the target stream. | 
|---|