Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
  public
  
  
  
  interface
  ObjectInput
  
  
      implements
      
        AutoCloseable, 
      
        DataInput
      
  
  
  
  
    
      | 
          Known indirect subclasses
          
  
  
    
  
  
    
      
        | ObjectInputStream | An ObjectInputStream deserializes primitive data and objects previously
 written using an ObjectOutputStream. |  | 
  
    
  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.
  
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 | 
|---|
|  | 
| 
    From interface
      
        
          java.io.DataInput
        
      
      
  
  
  
    | 
        abstract
        
        
        
        
        boolean | 
      readBoolean()
      Reads one input byte and returns
 trueif that byte is nonzero,falseif that byte is zero. |  
  
  
    | 
        abstract
        
        
        
        
        byte | 
      readByte()
      Reads and returns one input byte.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        char | 
      readChar()
      Reads two input bytes and returns a charvalue. |  
  
  
    | 
        abstract
        
        
        
        
        double | 
      readDouble()
      Reads eight input bytes and returns
 a doublevalue. |  
  
  
    | 
        abstract
        
        
        
        
        float | 
      readFloat()
      Reads four input bytes and returns
 a floatvalue. |  
  
  
    | 
        abstract
        
        
        
        
        void | 
      readFully(byte[] b)
      Reads some bytes from an input
 stream and stores them into the buffer
 array b. |  
  
  
    | 
        abstract
        
        
        
        
        void | 
      readFully(byte[] b, int off, int len)
      Reads lenbytes from
 an input stream. |  
  
  
    | 
        abstract
        
        
        
        
        int | 
      readInt()
      Reads four input bytes and returns an
 intvalue. |  
  
  
    | 
        abstract
        
        
        
        
        String | 
      readLine()
      Reads the next line of text from the input stream.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        long | 
      readLong()
      Reads eight input bytes and returns
 a longvalue. |  
  
  
    | 
        abstract
        
        
        
        
        short | 
      readShort()
      Reads two input bytes and returns
 a shortvalue. |  
  
  
    | 
        abstract
        
        
        
        
        String | 
      readUTF()
      Reads in a string that has been encoded using a
 modified UTF-8
 format.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        int | 
      readUnsignedByte()
      Reads one input byte, zero-extends
 it to type int, and returns
 the result, which is therefore in the range0through255. |  
  
  
    | 
        abstract
        
        
        
        
        int | 
      readUnsignedShort()
      Reads two input bytes and returns
 an intvalue in the range0through65535. |  
  
  
    | 
        abstract
        
        
        
        
        int | 
      skipBytes(int n)
      Makes an attempt to skip over
 nbytes
 of data from the input
 stream, discarding the skipped bytes. |  | 
Public methods
    available
    
public abstract int available ()
    
    
    
  Returns the number of bytes that can be read
 without blocking.
    
      | Returns | 
|---|
      
        | int | the number of available bytes. | 
    
      
  
 
    close
    
public abstract void close ()
    
    
    
  Closes the input stream. Must be called
 to release any resources associated with
 the stream.
      
  
 
    read
    
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. | 
    
      
  
 
    read
    
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. | 
    
      
  
 
    read
    
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. | 
    
      
  
 
    readObject
    
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 | 
    
      
  
 
    skip
    
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. | 
    
      
  
 
 
 
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  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 2025-02-10 UTC.
  
  
  
    
      [null,null,["Last updated 2025-02-10 UTC."],[],[]]