Interface RandomAccessRead

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default int available()
      Returns an estimate of the number of bytes that can be read.
      RandomAccessReadView createView​(long startPosition, long streamLength)
      Creates a random access read view starting at the given position with the given length.
      long getPosition()
      Returns offset of next byte to be returned by a read method.
      boolean isClosed()
      Returns true if this source has been closed.
      boolean isEOF()
      A simple test to see if we are at the end of the data.
      long length()
      The total number of bytes that are available.
      default int peek()
      This will peek at the next byte.
      int read()
      Read a single byte of data.
      default int read​(byte[] b)
      Read a buffer of data.
      int read​(byte[] b, int offset, int length)
      Read a buffer of data.
      default void rewind​(int bytes)
      Seek backwards the given number of bytes.
      void seek​(long position)
      Seek to a position in the data.
      default void skip​(int length)
      Skips a given number of bytes.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • read

        int read()
          throws java.io.IOException
        Read a single byte of data.
        Returns:
        The byte of data that is being read.
        Throws:
        java.io.IOException - If there is an error while reading the data.
      • read

        default int read​(byte[] b)
                  throws java.io.IOException
        Read a buffer of data.
        Parameters:
        b - The buffer to write the data to.
        Returns:
        The number of bytes that were actually read.
        Throws:
        java.io.IOException - If there was an error while reading the data.
      • read

        int read​(byte[] b,
                 int offset,
                 int length)
          throws java.io.IOException
        Read a buffer of data.
        Parameters:
        b - The buffer to write the data to.
        offset - Offset into the buffer to start writing.
        length - The amount of data to attempt to read.
        Returns:
        The number of bytes that were actually read.
        Throws:
        java.io.IOException - If there was an error while reading the data.
      • getPosition

        long getPosition()
                  throws java.io.IOException
        Returns offset of next byte to be returned by a read method.
        Returns:
        offset of next byte which will be returned with next read() (if no more bytes are left it returns a value >= length of source)
        Throws:
        java.io.IOException - If there was an error while getting the current position
      • seek

        void seek​(long position)
           throws java.io.IOException
        Seek to a position in the data.
        Parameters:
        position - The position to seek to.
        Throws:
        java.io.IOException - If there is an error while seeking.
      • length

        long length()
             throws java.io.IOException
        The total number of bytes that are available.
        Returns:
        The number of bytes available.
        Throws:
        java.io.IOException - If there is an IO error while determining the length of the data stream.
      • isClosed

        boolean isClosed()
        Returns true if this source has been closed.
        Returns:
        true if the source has been closed
      • peek

        default int peek()
                  throws java.io.IOException
        This will peek at the next byte.
        Returns:
        The next byte on the stream, leaving it as available to read.
        Throws:
        java.io.IOException - If there is an error reading the next byte.
      • rewind

        default void rewind​(int bytes)
                     throws java.io.IOException
        Seek backwards the given number of bytes.
        Parameters:
        bytes - the number of bytes to be seeked backwards
        Throws:
        java.io.IOException - If there is an error while seeking
      • isEOF

        boolean isEOF()
               throws java.io.IOException
        A simple test to see if we are at the end of the data.
        Returns:
        true if we are at the end of the data.
        Throws:
        java.io.IOException - If there is an error reading the next byte.
      • available

        default int available()
                       throws java.io.IOException
        Returns an estimate of the number of bytes that can be read.
        Returns:
        the number of bytes that can be read
        Throws:
        java.io.IOException - if this random access has been closed
      • skip

        default void skip​(int length)
                   throws java.io.IOException
        Skips a given number of bytes.
        Parameters:
        length - the number of bytes to be skipped
        Throws:
        java.io.IOException - if an I/O error occurs while reading data
      • createView

        RandomAccessReadView createView​(long startPosition,
                                        long streamLength)
                                 throws java.io.IOException
        Creates a random access read view starting at the given position with the given length.
        Parameters:
        startPosition - start position within the underlying random access read
        streamLength - stream length
        Returns:
        the random access read view
        Throws:
        java.io.IOException - if something went wrong when creating the view for the RandomAccessRead