|
Chapter 11 The java.io Package |
|
ObjectOutput
Name
ObjectOutput
- Interface Name:
-
java.io.ObjectOutput
- Super-interface:
-
java.io.DataOutput
- Immediate Sub-interfaces:
-
None
- Implemented By:
-
java.io.ObjectOutputStream
- Availability:
-
New as of JDK 1.1
The ObjectOutput interface
extends the DataOutput interface
for object serialization. While DataOutput
defines methods for reading primitive types from a stream, ObjectOutput
defines methods for writing objects and arrays of bytes.
public abstract interface java.io.ObjectOutput extends java.io.DataOutput {
// Methods
public abstract void close();
public abstract void flush();
public abstract void write(int b);
public abstract void write(byte[] b);
public abstract void write(byte[] b, int off, int len);
public abstract void writeObject(Object obj);
}
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Description
-
This method closes the stream and releases any system resources associated
with it.
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Description
-
If the stream uses a buffer, this method forces any bytes that may be buffered
by the output stream to be written to the underlying physical device.
- Parameters
-
- b
-
The value to write.
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Overrides
-
DataOutput.write(int)
- Description
-
This method writes the lowest eight bits of the given integer b
to the stream.
- Parameters
-
- b
-
An array of bytes to
write to the stream.
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Overrides
-
DataOutput.write(byte[])
- Description
-
This method writes all of the 8-bit bytes in the given array to the
stream.
- Parameters
-
- b
-
An array of bytes to
write to the stream.
- off
-
An offset into the
byte array.
- len
-
The number of bytes
to write.
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Overrides
-
DataOutput.write(byte[], int, int)
- Description
-
This method writes len bytes
from the given array, starting off
elements from the beginning of the array, to the stream.
- Throws
-
- IOException
-
If any kind
of I/O error occurs.
- Description
-
This method writes the given object to the stream, or in other words, it
serializes an object to the stream. The class that implements this interface
determines how the object is written.
DataOutput,
ObjectOutputStream
|
|