Interface DataInputStream

All Superinterfaces:
AutoCloseable, Closeable

public interface DataInputStream extends Closeable

The data input stream provides a means for reading data from a stream.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests if the end of this stream has been reached.
    long
    Gets the number of bytes available for retrieval.
    void
    Closes this stream and frees up any allocated resources.
    long
    read(byte[] buf, long n)
    Reads a specified number of bytes from this stream.
    long
    skip(long n)
    Skips a specified number of bytes in the stream.
  • Method Details

    • atEndOfStream

      boolean atEndOfStream()
      Tests if the end of this stream has been reached. This may not be a permanent condition as more data may be available at a later time as in the case of tailing a file.
      Returns:
      true if the end of this stream has been reached, false otherwise
      Throws:
      IllegalStateException - this stream has been closed
      Compliance:
      mandatory - This method must be implemented.
    • available

      long available()
      Gets the number of bytes available for retrieval. The number returned by this method may be less than or equal to the total number of bytes in this stream.
      Returns:
      the number of bytes available for retrieval
      Throws:
      IllegalStateException - this stream has been closed
      Compliance:
      mandatory - This method must be implemented.
    • skip

      long skip(long n)
      Skips a specified number of bytes in the stream.
      Parameters:
      n - the number of bytes to skip
      Returns:
      the actual number of bytes skipped
      Throws:
      IllegalStateException - this stream has been closed or atEndOfStream() is true
      Compliance:
      mandatory - This method must be implemented.
    • read

      long read(byte[] buf, long n) throws OperationFailedException
      Reads a specified number of bytes from this stream.
      Parameters:
      buf - the buffer in which the data is read
      n - the number of bytes to read
      Returns:
      the actual number of bytes read
      Throws:
      IllegalStateException - this stream has been closed or atEndOfStream() is true
      InvalidArgumentException - the size of buf is less than n
      NullArgumentException - buf is null
      OperationFailedException - unable to complete request
      Compliance:
      mandatory - This method must be implemented.
    • close

      void close()
      Closes this stream and frees up any allocated resources. Methods in this object may not be invoked after this method is called.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IllegalStateException - this stream has been closed
      Compliance:
      mandatory - This method must be implemented.