Package loci.common

Interface IRandomAccess

    • Method Detail

      • close

        void close()
            throws IOException
        Closes this random access stream and releases any system resources associated with the stream.
        Throws:
        IOException - if the underlying stream(s) could not be closed
      • getFilePointer

        long getFilePointer()
                     throws IOException
        Returns the current offset in this stream.
        Returns:
        the current byte offset within the file; expected to be non-negative and less than the value of #length()
        Throws:
        IOException - if the offset cannot be retrieved
      • exists

        boolean exists()
                throws IOException
        Returns whether this refers to a valid object
        Returns:
        true if this refers to a valid object
        Throws:
        IOException - if unable to determine whether the object is valid
      • length

        long length()
             throws IOException
        Returns the length of this stream.
        Returns:
        the length in bytes of the stream
        Throws:
        IOException - if the length cannot be retrieved
      • getOrder

        ByteOrder getOrder()
        Returns the current order (endianness) of the stream.
        Returns:
        See above.
      • setOrder

        void setOrder​(ByteOrder order)
        Sets the byte order (endianness) of the stream.
        Parameters:
        order - Order to set.
      • read

        int read​(byte[] b)
          throws IOException
        Reads up to b.length bytes of data from this stream into an array of bytes.
        Parameters:
        b - the array to fill from this stream
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - if reading is not possible
      • read

        int read​(byte[] b,
                 int off,
                 int len)
          throws IOException
        Reads up to len bytes of data from this stream into an array of bytes.
        Parameters:
        b - the array to fill from this stream
        off - the offset in b from which to start filling; expected to be non-negative and no greater than b.length - len
        len - the number of bytes to read; expected to be positive and no greater than b.length - offset
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - if reading is not possible
      • read

        int read​(ByteBuffer buffer)
          throws IOException
        Reads up to buffer.capacity() bytes of data from this stream into a ByteBuffer.
        Parameters:
        buffer - the ByteBuffer to fill from this stream
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - if reading is not possible
      • read

        int read​(ByteBuffer buffer,
                 int offset,
                 int len)
          throws IOException
        Reads up to len bytes of data from this stream into a ByteBuffer.
        Parameters:
        buffer - the ByteBuffer to fill from this stream
        offset - the offset in b from which to start filling; expected to be non-negative and no greater than buffer.capacity() - len
        len - the number of bytes to read; expected to be positive and no greater than buffer.capacity() - offset
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - if reading is not possible
      • seek

        void seek​(long pos)
           throws IOException
        Sets the stream pointer offset, measured from the beginning of this stream, at which the next read or write occurs.
        Parameters:
        pos - new byte offset (pointer) in the current stream. Unless otherwise noted, may be larger or smaller than the current pointer, but must be non-negative and less than the value of #length()
        Throws:
        IOException - if pos is invalid or the seek fails
        See Also:
        getFilePointer()
      • write

        void write​(ByteBuffer buf)
            throws IOException
        Writes up to buffer.capacity() bytes of data from the given ByteBuffer to this stream.
        Parameters:
        buf - the ByteBuffer containing bytes to write to this stream
        Throws:
        IOException - if writing is not possible
      • write

        void write​(ByteBuffer buf,
                   int off,
                   int len)
            throws IOException
        Writes up to len bytes of data from the given ByteBuffer to this stream.
        Parameters:
        buf - the ByteBuffer containing bytes to write to this stream
        off - the offset in b from which to start writing; expected to be non-negative and no greater than buf.capacity() - len
        len - the number of bytes to write; expected to be positive and no greater than buf.capacity() - offset
        Throws:
        IOException - if writing is not possible