Code example for CountingOutputStream

Methods: flush

0
 
	public void write(InputStream is) throws IOException {
		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 long getBytesWritten() { 
		return out.getCount();
	} 
} 
Contextual code suggestions in your IDE  Get Codota for Java