List of usage examples for org.apache.commons.compress.compressors.deflate DeflateCompressorOutputStream DeflateCompressorOutputStream
public DeflateCompressorOutputStream(final OutputStream outputStream, final DeflateParameters parameters) throws IOException
From source file:com.chenshu.compress.CompressOldTest.java
@Benchmark public int commonsDeflateCompress() { ByteArrayOutputStream bout = null; DeflateCompressorOutputStream dout = null; try {/*w ww. j av a2 s . c om*/ DeflateParameters p = new DeflateParameters(); p.setCompressionLevel(level); bout = new ByteArrayOutputStream(data.length); dout = new DeflateCompressorOutputStream(bout, p); dout.write(data); } catch (IOException e) { e.printStackTrace(); } finally { if (dout != null) { try { dout.close(); } catch (IOException e) { e.printStackTrace(); } } if (bout != null) { try { bout.close(); } catch (IOException e) { e.printStackTrace(); } } } byte[] bs = bout.toByteArray(); return bs.length; }