public void readFully(final long startPos, final int length, @NonNull final byte[] buffer) throws IOException {
        final int readBytes = readFile(this.fileChannel, startPos, length, buffer, 0);
        if (readBytes != length) {
            throw new IOException("Could not read requested number of bytes (" + buffer.length + "), read only " + readBytes + " bytges");
        }
    }
Reads bytes from a file

@param startPos position to read from in the file
@param length   number of bytes to read
@param buffer   buffer to store read bytes in
@throws IOException in case anything goes wrong
main/src/main/java/cgeo/geocaching/storage/FileByteReader.java