Interface StreamHandle<L extends Location>

    • Method Detail

      • in

        InputStream in()
                throws IOException
        Gets an input stream for reading data, positioned at the current offset.
        Returns:
        the appropriate input stream, or null if the handle is write-only.
        Throws:
        IOException
      • out

        OutputStream out()
                  throws IOException
        Gets an output stream for writing data, positioned at the current offset.
        Returns:
        the appropriate output stream, or null if the handle is read-only.
        Throws:
        IOException
      • setOffset

        void setOffset​(long offset)
        Sets the offset of the handle to the given position.

        This method is intended to be called only in conjunction with reading from the input stream, or writing to the output stream. Otherwise, the contents may get out of sync.

      • advance

        default void advance​(long bytes)
                      throws IOException
        Increments the handle's offset by the given amount.

        This method is intended to be called only in conjunction with reading from the input stream, or writing to the output stream. Otherwise, the contents may get out of sync.

        Throws:
        IOException
      • seek

        default void seek​(long pos)
                   throws IOException
        Description copied from interface: DataHandle
        Sets the stream offset, measured from the beginning of the stream, at which the next read or write occurs.
        Specified by:
        seek in interface DataHandle<L extends Location>
        Throws:
        IOException
      • resetStream

        void resetStream()
                  throws IOException
        Resets the stream to its start.
        Throws:
        IOException - If something goes wrong with the reset
      • ensureWritable

        default boolean ensureWritable​(long count)
                                throws IOException
        Description copied from interface: DataHandle
        Ensures that the handle has the correct length to be written to, and extends it as required.
        Specified by:
        ensureWritable in interface DataHandle<L extends Location>
        Parameters:
        count - Number of bytes to write.
        Returns:
        true if the handle's length was sufficient, or false if the handle's length required an extension.
        Throws:
        IOException - If the handle is read-only, or something goes wrong with the check, or there is an error changing the handle's length.
      • read

        default int read()
                  throws IOException
        Description copied from interface: DataHandle
        Reads the next byte of data from the stream.
        Specified by:
        read in interface DataHandle<L extends Location>
        Returns:
        the next byte of data, or -1 if the end of the stream is reached.
        Throws:
        IOException - - if an I/O error occurs.
      • read

        default int read​(byte[] b,
                         int off,
                         int len)
                  throws IOException
        Description copied from interface: DataHandle
        Reads up to len bytes of data from the stream into an array of bytes.
        Specified by:
        read in interface DataHandle<L extends Location>
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException