Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ObjectInput

public interface ObjectInput
implements DataInput, AutoCloseable

java.io.ObjectInput
Known Indirect Subclasses


Defines an interface for classes that allow reading serialized objects.

See also:

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)

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 int read(byte[] buffer, int byteOffset, int byteCount)

Reads up to byteCount bytes from this stream and stores them in byte array buffer starting at offset byteOffset.

abstract Object readObject()

Reads the next object from this stream.

abstract long skip(long byteCount)

Skips byteCount bytes on this stream.

Inherited methods

From interface java.io.DataInput
From interface java.lang.AutoCloseable

Public methods

available

Added in API level 1
int available ()

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

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

close

Added in API level 1
void close ()

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.

read

Added in API level 1
int read (byte[] buffer)

Reads bytes from this stream into the byte array buffer. Blocks while waiting for input. Returns the number of bytes read, or -1 if the end of this stream has been reached.

Parameters
buffer byte
Returns
int
Throws
IOException if this stream is closed or another I/O error occurs.

read

Added in API level 1
int read ()

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
int 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.

read

Added in API level 1
int read (byte[] buffer, 
                int byteOffset, 
                int byteCount)

Reads up to byteCount bytes from this stream and stores them in byte array buffer starting at offset byteOffset. Blocks while waiting for input. Returns the number of bytes read or -1 if the end of this stream has been reached.

Parameters
buffer byte
byteOffset int
byteCount int
Returns
int
Throws
IOException if this stream is closed or another I/O error occurs.

readObject

Added in API level 1
Object readObject ()

Reads the next object from this stream.

Returns
Object 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.

skip

Added in API level 1
long skip (long byteCount)

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

Parameters
byteCount long
Returns
long the number of bytes actually skipped.
Throws
IOException if this stream is closed or another I/O error occurs.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.