Java Fundamental Classes Reference

Previous Chapter 11
The java.io Package
Next
 

ObjectOutput

Name

ObjectOutput

Synopsis

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

Description

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.

Interface Declaration

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);
}

Methods

close

public abstract void close() throws IOException

Throws

IOException

If any kind of I/O error occurs.

Description

This method closes the stream and releases any system resources associated with it.

flush

public abstract void flush() throws IOException

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.

write

public abstract void write(int b) throws IOException

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.

public abstract void write(byte[] b) throws IOException

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.

 public abstract void write(byte[] b, int off, int len) throws IOException 

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.

writeObject

public abstract void writeObject(Object obj) throws IOException

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.

Inherited Methods

Method Inherited From Method Inherited From

writeBoolean(boolean)

DataOutput

writeByte(int)

DataOutput

writeBytes(String)

DataOutput

writeChar(int)

DataOutput

writeChars(String)

DataOutput

writeDouble(double)

DataOutput

writeFloat(float)

DataOutput

writeInt(int)

DataOutput

writeLong(long)

DataOutput

writeShort(int)

DataOutput

writeUTF(String)

DataOutput

   

See Also

DataOutput, ObjectOutputStream


Previous Home Next
ObjectInputValidation Book Index ObjectOutputStream

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java
This HTML Help has been published using the chm2web software.