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);}
public override ByteBuffer Read(int length, long position){if (position >= size){throw new IndexOutOfRangeException("Unable to read " + length + " bytes from " +position + " in stream of length " + size);}int toRead = (int)Math.Min(length, size - position);return ByteBuffer.CreateBuffer(buffer, (int)position, toRead);}