@Override
	public int read(byte[] b, int bufferOffset, int len) throws IOException {
		long eof = provider.length();
		if (currentPosition >= eof) {
			return -1;
		}
		len = (int) Math.min(len, eof - currentPosition);
		byte[] bytes = provider.readBytes(currentPosition, len);
		System.arraycopy(bytes, 0, b, bufferOffset, len);
		currentPosition += len;
		return len;
	}
Creates an InputStream that uses a ByteProvider as its source of bytes.
 
@param provider the {@link ByteProvider} to wrap
@param startPosition starting position in the provider
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/ByteProviderInputStream.java