@Override public void write(byte[] data, int off, int len) throws IOException { if (params.withContentChecksum) { contentHash.update(data, off, len); } if (currentIndex + len > blockData.length) { flushBlock(); while (len > blockData.length) { System.arraycopy(data, off, blockData, 0, blockData.length); off += blockData.length; len -= blockData.length; currentIndex = blockData.length; flushBlock(); } } System.arraycopy(data, off, blockData, currentIndex, len); currentIndex += len; }
/** * Compresses all remaining data and writes it to the stream, * doesn't close the underlying stream. * @throws IOException if an error occurs */ public void finish() throws IOException { if (!finished) { if (currentIndex > 0) { flushBlock(); } writeTrailer(); finished = true; } }
@Override public void write(byte[] data, int off, int len) throws IOException { if (params.withContentChecksum) { contentHash.update(data, off, len); } if (currentIndex + len > blockData.length) { flushBlock(); while (len > blockData.length) { System.arraycopy(data, off, blockData, 0, blockData.length); off += blockData.length; len -= blockData.length; currentIndex = blockData.length; flushBlock(); } } System.arraycopy(data, off, blockData, currentIndex, len); currentIndex += len; }
/** * Compresses all remaining data and writes it to the stream, * doesn't close the underlying stream. * @throws IOException if an error occurs */ public void finish() throws IOException { if (!finished) { if (currentIndex > 0) { flushBlock(); } writeTrailer(); finished = true; } }