/** * Compresses the currently buffered chunk of data and sends it to the output stream * * @throws IOException if issues occur writing to stream */ protected void compressAndWrite() throws IOException { if (bufferIndex <= 0) { return; } deflater.setInput(buffer, 0, bufferIndex); deflater.finish(); final int compressedBytes = deflater.deflate(compressed); writeChunkHeader(compressedBytes); out.write(compressed, 0, compressedBytes); bufferIndex = 0; deflater.reset(); }
/** * Compresses the currently buffered chunk of data and sends it to the output stream * * @throws IOException if issues occur writing to stream */ protected void compressAndWrite() throws IOException { if (bufferIndex <= 0) { return; } deflater.setInput(buffer, 0, bufferIndex); deflater.finish(); final int compressedBytes = deflater.deflate(compressed); writeChunkHeader(compressedBytes); out.write(compressed, 0, compressedBytes); bufferIndex = 0; deflater.reset(); }