@Override
	public byte[] readNBytes(int len) throws IOException {
		len = Math.min(available(), len);
		byte[] result = new byte[len];
		buffer.get(offset, result);
		offset += len;
		return result;
	}
An input stream backed by a database chained buffer
Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBBufferInputStream.java