public interface

ObjectInput

implements DataInput
java.io.ObjectInput
Known Indirect Subclasses

Class Overview

Defines an interface for classes that allow reading serialized objects.

Summary

Public Methods
abstract int available()
Indicates the number of bytes of primitive data that can be read without blocking.
abstract void close()
Closes this stream.
abstract int read(byte[] buffer, int offset, int count)
Reads at most count bytes from this stream and stores them in byte array buffer starting at offset count.
abstract int read(byte[] buffer)
Reads bytes from this stream into the byte array buffer.
abstract int read()
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.
abstract Object readObject()
Reads the next object from this stream.
abstract long skip(long toSkip)
Skips toSkip bytes on this stream.
[Expand]
Inherited Methods
From interface java.io.DataInput

Public Methods

public abstract int available ()

Since: API Level 1

Indicates the number of bytes of primitive data that can be read without blocking.

Returns
  • the number of bytes available.
Throws
IOException if an I/O error occurs.

public abstract void close ()

Since: API Level 1

Closes this stream. Implementations of this method should free any resources used by the stream.

Throws
IOException if an I/O error occurs while closing the input stream.

public abstract int read (byte[] buffer, int offset, int count)

Since: API Level 1

Reads at most count bytes from this stream and stores them in byte array buffer starting at offset count. Blocks while waiting for input.

Parameters
buffer the array in which to store the bytes read.
offset the initial position in buffer to store the bytes read from this stream.
count the maximum number of bytes to store in buffer.
Returns
  • the number of bytes read or -1 if the end of this stream has been reached.
Throws
IOException if this stream is closed or another I/O error occurs.

public abstract int read (byte[] buffer)

Since: API Level 1

Reads bytes from this stream into the byte array buffer. Blocks while waiting for input.

Parameters
buffer the array in which to store the bytes read.
Returns
  • the number of bytes read or -1 if the end of this stream has been reached.
Throws
IOException if this stream is closed or another I/O error occurs.

public abstract int read ()

Since: API Level 1

Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of this stream has been reached. Blocks if no input is available.

Returns
  • the byte read or -1 if the end of this stream has been reached.
Throws
IOException if this stream is closed or another I/O error occurs.

public abstract Object readObject ()

Since: API Level 1

Reads the next object from this stream.

Returns
  • the object read.
Throws
ClassNotFoundException if the object's class cannot be found.
IOException if this stream is closed or another I/O error occurs.

public abstract long skip (long toSkip)

Since: API Level 1

Skips toSkip bytes on this stream. Less than toSkip byte are skipped if the end of this stream is reached before the operation completes.

Parameters
toSkip the number of bytes to skip.
Returns
  • the number of bytes actually skipped.
Throws
IOException if this stream is closed or another I/O error occurs.