Interface ByteProvider

    • Method Detail

      • getFSRL

        default FSRL getFSRL()
        Returns the FSRL of the underlying file for this byte provider, or null if this byte provider is not associated with a file.
        Returns:
        The FSRL of the underlying File, or null if no associated File.
      • getFile

        java.io.File getFile()
        Returns the underlying File for this ByteProvider, or null if this ByteProvider is not associated with a File.
        Returns:
        the underlying file for this byte provider
      • getName

        java.lang.String getName()
        Returns the name of the ByteProvider. For example, the underlying file name.
        Returns:
        the name of the ByteProvider or null if there is no name
      • getAbsolutePath

        java.lang.String getAbsolutePath()
        Returns the absolute path (similar to, but not a, URI) to the ByteProvider. For example, the complete path to the file.
        Returns:
        the absolute path to the ByteProvider or null if not associated with a File.
      • length

        long length()
             throws java.io.IOException
        Returns the length of the ByteProvider
        Returns:
        the length of the ByteProvider
        Throws:
        java.io.IOException - if an I/O error occurs
      • isValidIndex

        boolean isValidIndex​(long index)
        Returns true if the specified index is valid.
        Parameters:
        index - the index in the byte provider to check
        Returns:
        true if the specified index is valid
      • close

        void close()
            throws java.io.IOException
        Releases any resources the ByteProvider may have occupied
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if an I/O error occurs
      • readByte

        byte readByte​(long index)
               throws java.io.IOException
        Reads a byte at the specified index
        Parameters:
        index - the index of the byte to read
        Returns:
        the byte read from the specified index
        Throws:
        java.io.IOException - if an I/O error occurs
      • readBytes

        byte[] readBytes​(long index,
                         long length)
                  throws java.io.IOException
        Reads a byte array at the specified index
        Parameters:
        index - the index of the byte to read
        length - the number of bytes to read
        Returns:
        the byte array read from the specified index
        Throws:
        java.io.IOException - if an I/O error occurs
      • getInputStream

        default java.io.InputStream getInputStream​(long index)
                                            throws java.io.IOException
        Returns an input stream to the underlying byte provider starting at the specified index.

        The caller is responsible for closing the returned InputStream instance.

        If you need to override this default implementation, please document why your inputstream is needed.

        Parameters:
        index - where in the ByteProvider to start the InputStream
        Returns:
        the InputStream
        Throws:
        java.io.IOException - if an I/O error occurs