[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/java/io/ObjectInput [Back]  [Original]

ObjectInput  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.
Added in API level 1

ObjectInput

public interface ObjectInput
implements AutoCloseable, DataInput

java.io.ObjectInput


ObjectInput extends the DataInput interface to include the reading of objects. DataInput includes methods for the input of primitive types, ObjectInput extends that interface to include objects, arrays, and Strings.

See also:

Summary

Public methods

abstract int available()

Returns the number of bytes that can be read without blocking.

abstract void close()

Closes the input stream.

abstract int read()

Reads a byte of data.

abstract int read(byte[] b, int off, int len)

Reads into an array of bytes.

abstract int read(byte[] b)

Reads into an array of bytes.

abstract Object readObject()

Read and return an object.

abstract long skip(long n)

Skips n bytes of input.

Inherited methods

Public methods

available

Added in API level 1
public abstract int available ()

Returns the number of bytes that can be read without blocking.

Returns
int the number of available bytes.

Throws
IOException If an I/O error has occurred.

close

Added in API level 1
public abstract void close ()

Closes the input stream. Must be called to release any resources associated with the stream.

Throws
IOException If an I/O error has occurred.

read

Added in API level 1
public abstract int read ()

Reads a byte of data. This method will block if no input is available.

Returns
int the byte read, or -1 if the end of the stream is reached.

Throws
IOException If an I/O error has occurred.

read

Added in API level 1
public abstract int read (byte[] b, 
                int off, 
                int len)

Reads into an array of bytes. This method will block until some input is available.

Parameters
b byte: the buffer into which the data is read

off int: the start offset of the data

len int: the maximum number of bytes read

Returns
int the actual number of bytes read, -1 is returned when the end of the stream is reached.

Throws
IOException If an I/O error has occurred.

read

Added in API level 1
public abstract int read (byte[] b)

Reads into an array of bytes. This method will block until some input is available.

Parameters
b byte: the buffer into which the data is read

Returns
int the actual number of bytes read, -1 is returned when the end of the stream is reached.

Throws
IOException If an I/O error has occurred.

readObject

Added in API level 1
public abstract Object readObject ()

Read and return an object. The class that implements this interface defines where the object is "read" from.

Returns
Object the object read from the stream

Throws
IOException If any of the usual Input/Output related exceptions occur.
ClassNotFoundException If the class of a serialized object cannot be found.

skip

Added in API level 1
public abstract long skip (long n)

Skips n bytes of input.

Parameters
n long: the number of bytes to be skipped

Returns
long the actual number of bytes skipped.

Throws
IOException If an I/O error has occurred.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-08-03 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-03 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page