text: public ByteBuffer read(int length, long position) {if(position >= size) {throw new IndexOutOfBoundsException("Unable to read " + length + " bytes from " +position + " in stream of length " + size);}int toRead = (int)Math.min(length, size - position);return ByteBuffer.wrap(buffer, (int)position, toRead);}