接口 RandomAccessData

  • 所有已知实现类:
    RandomAccessDataFile

    public interface RandomAccessData
    Interface that provides read-only random access to some underlying data. Implementations must allow concurrent reads in a thread-safe manner.
    • 方法详细资料

      • getInputStream

        InputStream getInputStream()
                            throws IOException
        Returns an InputStream that can be used to read the underlying data. The caller is responsible close the underlying stream.
        返回:
        a new input stream that can be used to read the underlying data.
        抛出:
        IOException - if the stream cannot be opened
      • getSubsection

        RandomAccessData getSubsection​(long offset,
                                       long length)
        Returns a new RandomAccessData for a specific subsection of this data.
        参数:
        offset - the offset of the subsection
        length - the length of the subsection
        返回:
        the subsection data
      • read

        byte[] read()
             throws IOException
        Reads all the data and returns it as a byte array.
        返回:
        the data
        抛出:
        IOException - if the data cannot be read
      • read

        byte[] read​(long offset,
                    long length)
             throws IOException
        Reads the length bytes of data starting at the given offset.
        参数:
        offset - the offset from which data should be read
        length - the number of bytes to be read
        返回:
        the data
        抛出:
        IOException - if the data cannot be read
        IndexOutOfBoundsException - if offset is beyond the end of the file or subsection
        EOFException - if offset plus length is greater than the length of the file or subsection
      • getSize

        long getSize()
        Returns the size of the data.
        返回:
        the size