private int readPage(InputStream stream, ArrayIter buffer) throws IOException {
		int len = maxCount - byteCount;
		if (len > BUFFER_SIZE) {
			len = BUFFER_SIZE;
		}
		int pos = 0;
		do {
			int readLen = stream.read(currentBuffer.array, pos, len - pos);
			if (readLen < 0) {
				break;
			}
			pos += readLen;
		}
		while (pos < len);
		byteCount += pos;
		return pos;
	}
Read a page of data into the given buffer.  The buffer must already be allocated and
will be entirely filled, unless end-of-stream is reached.  The number of bytes
actually read into the buffer is returned.
@param stream is the stream
@param buffer is the allocated buffer
@return the number of bytes read
@throws IOException for problems reading from the stream
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/LinkedByteBuffer.java