@Override public OutputStream getOutputStream(OutputStream outputStream) throws IOException { final DeflaterOutputStream os = new DeflaterOutputStream(outputStream); if (flushMethod == FlushMethod.SYNC_FLUSH) { os.setSyncFlush(true); } return os; } }
@Override public void end() { if (finished) { return; } finished = true; z.deflateEnd(); z.next_in = null; z.next_out = null; } }
@Override public InputStream getInputStream(InputStream inputStream) throws IOException { final InflaterInputStream is = new InflaterInputStream(inputStream); return is; }
/** * Creates a new instance with the specified wrapper. * * @throws DecompressionException if failed to initialize zlib */ public JZlibDecoder(ZlibWrapper wrapper) { if (wrapper == null) { throw new NullPointerException("wrapper"); } int resultCode = z.init(ZlibUtil.convertWrapperType(wrapper)); if (resultCode != JZlib.Z_OK) { ZlibUtil.fail(z, "initialization failure", resultCode); } }
public void reset() { if (impl == null) { throw new NullPointerException(); } flushParm = Z_NO_FLUSH; finished = false; impl.init(compressLevel, strategy, nowrap); }
/** * Creates a new instance with the specified preset dictionary. The wrapper * is always {@link ZlibWrapper#ZLIB} because it is the only format that * supports the preset dictionary. * * @throws DecompressionException if failed to initialize zlib */ public JZlibDecoder(byte[] dictionary) { if (dictionary == null) { throw new NullPointerException("dictionary"); } this.dictionary = dictionary; int resultCode; resultCode = z.inflateInit(JZlib.W_ZLIB); if (resultCode != JZlib.Z_OK) { ZlibUtil.fail(z, "initialization failure", resultCode); } }
public TInflater(boolean noHeader) { nowrap = noHeader; try { impl = new Inflater(noHeader); } catch (GZIPException e) { // Do nothing } }
public InputStream extract(InputStream _in) throws IOException { HeadBufferingStream in = new HeadBufferingStream(_in,SIDE_BUFFER_SIZE); try { return new GZIPInputStream(in, 8192, true); } catch (IOException e) { // various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better in.fillSide(); throw new IOException(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e); } } public OutputStream compress(OutputStream out) throws IOException {
public OutputStream compress(OutputStream out) throws IOException { return new GZIPOutputStream(new BufferedOutputStream(out)); } };
public int getAdler() { if (impl == null) { throw new IllegalStateException(); } return (int) impl.getAdler(); }
@Override public void reset() { impl.reset(); tbytes = 0; }
@Override public long getValue() { return impl.getValue(); }
@Override public void update(int val) { impl.update(new byte[] { (byte) val }, 0, 1); }
public long getBytesWritten() { if (impl == null) { throw new IllegalStateException(); } return impl.getTotalOut(); }
public int getTotalOut() { if (impl == null) { throw new IllegalStateException(); } return (int) impl.getTotalOut(); }
public long getBytesRead() { // Throw NPE here if (impl == null) { throw new NullPointerException(); } return impl.getTotalIn(); }
@Override public long getValue() { return impl.getValue(); }
@Override public void reset() { impl.reset(); }
/** * Creates a new instance with the specified wrapper. * * @throws DecompressionException if failed to initialize zlib */ public JZlibDecoder(ZlibWrapper wrapper) { if (wrapper == null) { throw new NullPointerException("wrapper"); } int resultCode = z.init(ZlibUtil.convertWrapperType(wrapper)); if (resultCode != JZlib.Z_OK) { ZlibUtil.fail(z, "initialization failure", resultCode); } }