AI-generated Key Takeaways
-
The
ObjectOutputinterface defines methods for writing serialized objects to a stream. -
It extends
DataOutputandAutoCloseable, inheriting methods for writing various data types and closing the stream. -
Key methods include
writeObjectfor writing objects,writefor writing byte arrays and primitives, andclosefor closing the stream. -
ObjectOutputStreamis a known indirect subclass that implements this interface for writing objects to an output stream.
| Known Indirect Subclasses |
Defines an interface for classes that allow reading serialized objects.
See Also
Public Method Summary
| abstract void |
close()
Closes the target stream.
|
| abstract void |
flush()
Flushes the target stream.
|
| abstract void |
write(byte[] buffer)
Writes the entire contents of the byte array
buffer to the output
stream. |
| abstract void |
write(byte[] buffer, int offset, int count)
Writes
count bytes from the byte array buffer starting at
position offset to the target stream. |
| abstract void |
write(int value)
Writes a single byte to the target stream.
|
| abstract void |
Inherited Method Summary
Public Methods
public abstract void close ()
Closes the target stream. Implementations of this method should free any resources used by the stream.
Throws
| IOException | if an error occurs while closing the target stream. |
|---|
public abstract void flush ()
Flushes the target stream. Implementations of this method should ensure that any pending writes are written out to the target stream.
Throws
| IOException | if an error occurs while flushing the target stream. |
|---|
public abstract void write (byte[] buffer)
Writes the entire contents of the byte array buffer to the output
stream. Blocks until all bytes are written.
Parameters
| buffer | the buffer to write. |
|---|
Throws
| IOException | if an error occurs while writing to the target stream. |
|---|
public abstract void write (byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position offset to the target stream. Blocks until all bytes are
written.
Parameters
| buffer | the buffer to write. |
|---|---|
| offset | the index of the first byte in buffer to write. |
| count | the number of bytes from buffer to write to the target
stream. |
Throws
| IOException | if an error occurs while writing to the target stream. |
|---|
public abstract void write (int value)
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.
Parameters
| value | the byte to write. |
|---|
Throws
| IOException | if an error occurs while writing to the target stream. |
|---|
public abstract void writeObject (Object obj)
Writes the specified object obj to the target stream.
Parameters
| obj | the object to write. |
|---|
Throws
| IOException | if an error occurs while writing to the target stream. |
|---|