public synchronized void fill(InputStream in) throws IOException {
		if (readOnly) {
			throw new UnsupportedOperationException("Read-only buffer");
		}
		byte[] data = new byte[dataSpace];
		int index = 0;
		int offset = 0;
		int length = size;
		int readSpace = dataSpace;

		if (useXORMask) {
			xorData = new byte[dataSpace];
		}
		try {
			while (length > 0) {
				int readLen = Math.min(length, readSpace);
				int cnt = in.read(data, 0, readLen);
				if (cnt < 0) {
					break;
				}

				putBytes(index, offset, data, 0, readLen);

				readSpace -= cnt;
				offset += cnt;
				length -= cnt;

				if (readSpace == 0) {
					// move-on to next buffer
					++index;
					readSpace = dataSpace;
					offset = 0;
				}

			}
		}
		finally {
			xorData = null;
		}
	}
Fill buffer with data provided by InputStream.  If 
stream is exhausted, the remainder of the buffer will be filled
with 0's.
@param in data source
@throws IOException thrown if IO error occurs.
Ghidra/Framework/DB/src/main/java/db/ChainedBuffer.java