private void copyBlockData(InputBlockStream inputBlockStream, OutputStream out)
			throws IOException {

		if (compressed) {
			out = new DeflaterOutputStream(out, new Deflater(Deflater.BEST_SPEED));
		}

		int blocksRemaining = getBlockCount();

		BufferFileBlock block;
		while ((block = inputBlockStream.readBlock()) != null) {
			if (blocksRemaining == 0) {
				throw new IOException("unexpected data in stream");
			}
			out.write(block.toBytes());
			--blocksRemaining;
		}

		// done with compressed stream, force compressed data to flush
		if (out instanceof DeflaterOutputStream) {
			((DeflaterOutputStream) out).finish();
		}
	}
<code>ClientInputBlockStream</code> provides the client-side of an
InputBlockStream which wraps an optionally compressed socket input stream
Ghidra/Features/GhidraServer/src/main/java/ghidra/server/stream/RemoteInputBlockStreamHandle.java