Interface ByteProvider

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void close()
      Releases any resources the provider may have occupied.
      java.lang.String getAbsolutePath()
      Returns the absolute path (similar to, but not a, URI) to the byte provider.
      java.io.File getFile()
      Returns the underlying file for this byte provider.
      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.
      java.io.InputStream getInputStream​(long index)
      Returns an input stream to the underlying byte provider starting at the specified index
      java.lang.String getName()
      Returns the name of the byte provider.
      boolean isValidIndex​(long index)
      Returns true if the specified index is valid.
      long length()
      Returns the length of the underlying provider.
      byte readByte​(long index)
      Reads a byte at the specified index.
      byte[] readBytes​(long index, long length)
      Reads a byte array at the specified index.
    • 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:
        FSRL of the underlying file, or null if no associated file.
      • getFile

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

        java.lang.String getName()
        Returns the name of the byte provider. For example, the underlying file name.
        Returns:
        the name of the byte provider or null
      • getAbsolutePath

        java.lang.String getAbsolutePath()
        Returns the absolute path (similar to, but not a, URI) to the byte provider. For example, the complete path to the file.
        Returns:
        the absolute path to the byte provider or null
      • length

        long length()
             throws java.io.IOException
        Returns the length of the underlying provider.
        Returns:
        the length of the underlying provider
        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
        Returns:
        returns true if the specified index is valid
        Throws:
        java.io.IOException - if an I/O error occurs
      • close

        void close()
            throws java.io.IOException
        Releases any resources the provider 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 to read the byte
        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 to read the byte array
        length - the number of elements to read
        Returns:
        the byte array read from the specified index
        Throws:
        java.io.IOException - if an I/O error occurs
      • getInputStream

        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.

        Parameters:
        index - the index to initialize the input stream
        Returns:
        the input stream
        Throws:
        java.io.IOException - if an I/O error occurs