List of usage examples for org.apache.commons.compress.compressors CompressorOutputStream write
public void write(byte b[], int off, int len) throws IOException
len
bytes from the specified byte array starting at offset off
to this output stream. From source file:darks.codec.wrap.zip.CommonsCompress.java
/** * {@inheritDoc}// w ww . j ava 2s.co m */ @Override public void compress(InputStream input, OutputStream out) throws Exception { CompressorOutputStream cos = null; try { cos = factory.createCompressorOutputStream(type, out); byte[] buf = new byte[1024]; int len; while ((len = input.read(buf)) > 0) { cos.write(buf, 0, len); } cos.flush(); } catch (CompressorException e) { throw new Exception("Fail to compress data by commons compress. Cause " + e.getMessage(), e); } finally { IoHelper.closeIO(cos); } }