Code example for DeflaterOutputStream

Methods: finish

0
		CRCInputStream crc = new CRCInputStream(is);
		GZIPHeader gzHeader = new GZIPHeader();
		// TODO: add fields... 
		gzHeader.writeBytes(out);
		Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
		DeflaterOutputStream deflateOut = new DeflaterOutputStream(out,deflater);
		StreamCopy.copy(crc, deflateOut);
		deflateOut.finish();
		GZIPFooter gzFooter = new GZIPFooter(crc.getCRCValue(), crc.getByteCount());
		gzFooter.writeBytes(out);
		out.flush();
	} 
 
	public void writeWithLengthHeader(InputStream is) throws IOException {
 
		// stuff all the deflate data into the file backed OS: 
		FileBackedOutputStream outTmp = new FileBackedOutputStream(maxBuffer);
		 
		CRCInputStream crc = new CRCInputStream(is);
		Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
		DeflaterOutputStream deflateOut = new DeflaterOutputStream(outTmp,deflater);