# ObjectInput

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/java/io/ObjectInput#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/io/ObjectInput#inhmethods)  

# ObjectInput

`
public


interface
ObjectInput
`  
`


implements

`[AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)`,

`[DataInput](https://developer.android.com/reference/java/io/DataInput)`


`

|---------------------|
| java.io.ObjectInput |

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [ObjectInputStream](https://developer.android.com/reference/java/io/ObjectInputStream) |----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| | [ObjectInputStream](https://developer.android.com/reference/java/io/ObjectInputStream) | An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream. | |

<br />

*** ** * ** ***

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:**

- [InputStream](https://developer.android.com/reference/java/io/InputStream)
- [ObjectOutputStream](https://developer.android.com/reference/java/io/ObjectOutputStream)
- [ObjectInputStream](https://developer.android.com/reference/java/io/ObjectInputStream)

## Summary

|                                                                                                               ### Public methods                                                                                                               ||
|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract int`                                                                | ` `[available](https://developer.android.com/reference/java/io/ObjectInput#available())`() ` Returns the number of bytes that can be read without blocking.    |
| ` abstract void`                                                               | ` `[close](https://developer.android.com/reference/java/io/ObjectInput#close())`() ` Closes the input stream.                                                  |
| ` abstract int`                                                                | ` `[read](https://developer.android.com/reference/java/io/ObjectInput#read())`() ` Reads a byte of data.                                                       |
| ` abstract int`                                                                | ` `[read](https://developer.android.com/reference/java/io/ObjectInput#read(byte[],%20int,%20int))`(byte[] b, int off, int len) ` Reads into an array of bytes. |
| ` abstract int`                                                                | ` `[read](https://developer.android.com/reference/java/io/ObjectInput#read(byte[]))`(byte[] b) ` Reads into an array of bytes.                                 |
| ` abstract `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[readObject](https://developer.android.com/reference/java/io/ObjectInput#readObject())`() ` Read and return an object.                                      |
| ` abstract long`                                                               | ` `[skip](https://developer.android.com/reference/java/io/ObjectInput#skip(long))`(long n) ` Skips n bytes of input.                                           |

| ### Inherited methods |
|-----------------------|---|
| From interface` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||
| From interface` `[java.io.DataInput](https://developer.android.com/reference/java/io/DataInput)` ` |--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                            | ` `[readBoolean](https://developer.android.com/reference/java/io/DataInput#readBoolean())`() ` Reads one input byte and returns`true`if that byte is nonzero,`false`if that byte is zero.                                                 | | ` abstract byte`                                                               | ` `[readByte](https://developer.android.com/reference/java/io/DataInput#readByte())`() ` Reads and returns one input byte.                                                                                                                | | ` abstract char`                                                               | ` `[readChar](https://developer.android.com/reference/java/io/DataInput#readChar())`() ` Reads two input bytes and returns a`char`value.                                                                                                  | | ` abstract double`                                                             | ` `[readDouble](https://developer.android.com/reference/java/io/DataInput#readDouble())`() ` Reads eight input bytes and returns a`double`value.                                                                                          | | ` abstract float`                                                              | ` `[readFloat](https://developer.android.com/reference/java/io/DataInput#readFloat())`() ` Reads four input bytes and returns a`float`value.                                                                                              | | ` abstract void`                                                               | ` `[readFully](https://developer.android.com/reference/java/io/DataInput#readFully(byte[]))`(byte[] b) ` Reads some bytes from an input stream and stores them into the buffer array`b`.                                                  | | ` abstract void`                                                               | ` `[readFully](https://developer.android.com/reference/java/io/DataInput#readFully(byte[],%20int,%20int))`(byte[] b, int off, int len) ` Reads`len`bytes from an input stream.                                                            | | ` abstract int`                                                                | ` `[readInt](https://developer.android.com/reference/java/io/DataInput#readInt())`() ` Reads four input bytes and returns an`int`value.                                                                                                   | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[readLine](https://developer.android.com/reference/java/io/DataInput#readLine())`() ` Reads the next line of text from the input stream.                                                                                               | | ` abstract long`                                                               | ` `[readLong](https://developer.android.com/reference/java/io/DataInput#readLong())`() ` Reads eight input bytes and returns a`long`value.                                                                                                | | ` abstract short`                                                              | ` `[readShort](https://developer.android.com/reference/java/io/DataInput#readShort())`() ` Reads two input bytes and returns a`short`value.                                                                                               | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[readUTF](https://developer.android.com/reference/java/io/DataInput#readUTF())`() ` Reads in a string that has been encoded using a[modified UTF-8](https://developer.android.com/reference/java/io/ObjectInput#modified-utf-8)format. | | ` abstract int`                                                                | ` `[readUnsignedByte](https://developer.android.com/reference/java/io/DataInput#readUnsignedByte())`() ` Reads one input byte, zero-extends it to type`int`, and returns the result, which is therefore in the range`0`through`255`.      | | ` abstract int`                                                                | ` `[readUnsignedShort](https://developer.android.com/reference/java/io/DataInput#readUnsignedShort())`() ` Reads two input bytes and returns an`int`value in the range`0`through`65535`.                                                  | | ` abstract int`                                                                | ` `[skipBytes](https://developer.android.com/reference/java/io/DataInput#skipBytes(int))`(int n) ` Makes an attempt to skip over`n`bytes of data from the input stream, discarding the skipped bytes.                                     | ||

## Public methods

### available

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int available ()
```

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

<br />

|                   Returns                    ||
|-------|---------------------------------------|
| `int` | the number of available bytes. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |

### close

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void close ()
```

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

<br />

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |

### read

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int read ()
```

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

<br />

|                                 Returns                                 ||
|-------|------------------------------------------------------------------|
| `int` | the byte read, or -1 if the end of the stream is reached. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |

### read

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

<br />

|                          Parameters                          ||
|-------|-------------------------------------------------------|
| `b`   | `byte`: the buffer into which the data is read <br /> |
| `off` | `int`: the start offset of the data <br />            |
| `len` | `int`: the maximum number of bytes read <br />        |

|                                               Returns                                                ||
|-------|-----------------------------------------------------------------------------------------------|
| `int` | the actual number of bytes read, -1 is returned when the end of the stream is reached. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |

### read

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int read (byte[] b)
```

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

<br />

|                         Parameters                         ||
|-----|-------------------------------------------------------|
| `b` | `byte`: the buffer into which the data is read <br /> |

|                                               Returns                                                ||
|-------|-----------------------------------------------------------------------------------------------|
| `int` | the actual number of bytes read, -1 is returned when the end of the stream is reached. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |

### readObject

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Object readObject ()
```

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

<br />

|                                                  Returns                                                   ||
|--------------------------------------------------------------------|----------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | the object read from the stream <br /> |

|                                                                             Throws                                                                             ||
|----------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException) | If the class of a serialized object cannot be found.       |
| [IOException](https://developer.android.com/reference/java/io/IOException)                         | If any of the usual Input/Output related exceptions occur. |

### skip

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract long skip (long n)
```

Skips n bytes of input.

<br />

|                      Parameters                       ||
|-----|--------------------------------------------------|
| `n` | `long`: the number of bytes to be skipped <br /> |

|                      Returns                       ||
|--------|--------------------------------------------|
| `long` | the actual number of bytes skipped. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error has occurred. |