public ByteBuffer read(int length, long position) throws IOException {if(position >= size()) {throw new IndexOutOfBoundsException("Position " + position + " past the end of the file");}ByteBuffer dst;if (writable) {dst = channel.map(FileChannel.MapMode.READ_WRITE, position, length);buffersToClean.add(dst);} else {channel.position(position);dst = ByteBuffer.allocate(length);int worked = IOUtils.readFully(channel, dst);if(worked == -1) {throw new IndexOutOfBoundsException("Position " + position + " past the end of the file");}}dst.position(0);return dst;}