Class InMemoryRandomAccessFile

    • Constructor Detail

      • InMemoryRandomAccessFile

        public InMemoryRandomAccessFile​(String name,
                                        byte[] data)
        Constructor.
        Parameters:
        name - used as the location
        data - the complete data file
    • Method Detail

      • length

        public long length()
        Description copied from class: RandomAccessFile
        Get the length of the file. The data in the buffer (which may not have been written the disk yet) is taken into account.
        Overrides:
        length in class RandomAccessFile
        Returns:
        the length of the file in bytes.
      • setBufferSize

        public void setBufferSize​(int bufferSize)
        Description copied from class: RandomAccessFile
        Set the buffer size. If writing, call flush() first.
        Overrides:
        setBufferSize in class RandomAccessFile
        Parameters:
        bufferSize - length in bytes
      • read_

        protected int read_​(long pos,
                            byte[] b,
                            int offset,
                            int len)
        Description copied from class: RandomAccessFile
        Read directly from file, without going through the buffer. All reading goes through here or readToByteChannel;
        Overrides:
        read_ in class RandomAccessFile
        Parameters:
        pos - start here in the file
        b - put data into this buffer
        offset - buffer offset
        len - this number of bytes
        Returns:
        actual number of bytes read, -1 if underlying random access file was closed
      • readToByteChannel

        public long readToByteChannel​(WritableByteChannel dest,
                                      long offset,
                                      long nbytes)
                               throws IOException
        Description copied from class: RandomAccessFile
        Read nbytes bytes, at the specified file offset, send to a WritableByteChannel. This will block until all bytes are read. This uses the underlying file channel directly, bypassing all user buffers.
        Overrides:
        readToByteChannel in class RandomAccessFile
        Parameters:
        dest - write to this WritableByteChannel.
        offset - the offset in the file where copying will start.
        nbytes - the number of bytes to read.
        Returns:
        the actual number of bytes read and transfered
        Throws:
        IOException - if an I/O error occurs.