Code example for MappedByteBuffer

Methods: positionremainingduplicate

     * @return buffer with portion of file content 
     * @throws IOException on any fail of I/O operation 
    public synchronized ByteBuffer readBytes(int length) throws IOException
        int remaining = buffer.remaining() - position;
        if (length > remaining)
            throw new IOException(String.format("mmap segment underflow; remaining is %d but %d requested",
                                                remaining, length));
        ByteBuffer bytes = buffer.duplicate();
        bytes.position(buffer.position() + position).limit(buffer.position() + position + length);
        position += length;
        return bytes;
    public final void readFully(byte[] buffer) throws IOException
Connect your IDE to all the code out there  Get Codota for Java