java.util.zip

Class Inflater


public class Inflater
extends Object

This class provides support for general purpose decompression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.

The following code fragment demonstrates a trivial compression and decompression of a string using Deflater and Inflater.

 // Encode a String into bytes
 String inputString = "blahblahblah\u20AC\u20AC";
 byte[] input = inputString.getBytes("UTF-8");

 // Compress the bytes
 byte[] output = new byte[100];
 Deflater compresser = new Deflater();
 compresser.setInput(input);
 compresser.finish();
 int compressedDataLength = compresser.deflate(output);

 // Decompress the bytes
 Inflater decompresser = new Inflater();
 decompresser.setInput(output, 0, compressedDataLength);
 byte[] result = new byte[100];
 int resultLength = decompresser.inflate(result);
 decompresser.end();

 // Decode the bytes into a String
 String outputString = new String(result, 0, resultLength, "UTF-8");
 
See Also:
Deflater

Constructor Summary

Inflater()
Creates a new decompressor.
Inflater(boolean nowrap)
Creates a new decompressor.

Method Summary

void
end()
Closes the decompressor and discards any unprocessed input.
protected void
finalize()
Closes the decompressor when garbage is collected.
boolean
finished()
Returns true if the end of the compressed data stream has been reached.
int
getAdler()
Returns the ADLER-32 value of the uncompressed data.
long
getBytesRead()
Returns the total number of compressed bytes input so far.
long
getBytesWritten()
Returns the total number of uncompressed bytes output so far.
int
getRemaining()
Returns the total number of bytes remaining in the input buffer.
int
getTotalIn()
Returns the total number of compressed bytes input so far.
int
getTotalOut()
Returns the total number of uncompressed bytes output so far.
int
inflate(byte[] b)
Uncompresses bytes into specified buffer.
int
inflate(byte[] b, int off, int len)
Uncompresses bytes into specified buffer.
boolean
needsDictionary()
Returns true if a preset dictionary is needed for decompression.
boolean
needsInput()
Returns true if no data remains in the input buffer.
void
reset()
Resets inflater so that a new set of input data can be processed.
void
setDictionary(byte[] b)
Sets the preset dictionary to the given array of bytes.
void
setDictionary(byte[] b, int off, int len)
Sets the preset dictionary to the given array of bytes.
void
setInput(byte[] b)
Sets input data for decompression.
void
setInput(byte[] b, int off, int len)
Sets input data for decompression.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Inflater

public Inflater()
Creates a new decompressor.
Usages and Demos :

View More Examples of Inflater()
   1:     super(in);
   2:     decompressor = new Inflater();
   3:     buffer = new byte[8192];
   4:     bufferSize = 0;
   5:     bufferOffset = 0;

View Full Code Here
   1: 
   2:          Inflater inflater = new Inflater();
   3:          inflater.setInput(input, 4, input.length - 4);
   4:          inflater.finished();
   5:          

View Full Code Here
   1: 
   2:             Inflater inflater = new Inflater();
   3:             inflater.setInput(input, 4, input.length - 4);
   4:             inflater.finished();

View Full Code Here
   1:         byte[] result =  new byte[Math.max(inPacket.length()*10+300, DonkeyPacketConstants.BLOCKSIZE + 30)];
   2:         Inflater decompresser = new Inflater();
   3:         ByteBuffer body = inPacket.getBuffer();
   4:         body.position(6);
   5:         body.get(compressedData);

View Full Code Here
   1:         maxReadIndex = 0;
   2:         inflater = new Inflater();
   3:     }
   4: 
   5:     public boolean markSupported() {

View Full Code Here

Inflater

public Inflater(boolean nowrap)
Creates a new decompressor. If the parameter 'nowrap' is true then the ZLIB header and checksum fields will not be used. This provides compatibility with the compression format used by both GZIP and PKZIP.

Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations.

Parameters:
nowrap - if true then support GZIP compatible compression
Usages and Demos :

View More Examples of Inflater(boolean nowrap)
   1:         super(hasDummyTrailingByte ? in : new SequenceInputStream(in, new ByteArrayInputStream(new byte[1])),
   2:               new Inflater(true),
   3:         }
   4: 
   5:     public DefInputStream(final InputStream in)

View Full Code Here
   1:     {
   2:         super(in, new Inflater(true), size);
   3:         readHeader();
   4:         crc.reset();
   5:     }

View Full Code Here
   1: 
   2:     _inflater = new Inflater(true);
   3:     _crc = new CRC32();
   4:     _eof = false;

View Full Code Here
   1:     public ResettableGZIPInputStream() {
   2:         super(new LookaheadInputStream(FOOTER_SIZE), new Inflater(true));
   3:         _lookaheadStream = (LookaheadInputStream)in;
   4:         _crc32 = new CRC32();
   5:         _complete = false;

View Full Code Here
   1:             if (compression != -1) {
   2:                 inflator = new Inflater(true);
   3:                 deflater = new Deflater(compression, true);
   4:         ...
   5:         if (compression != -1) {
   6:             inflator = new Inflater(true);
   7:             deflater = new Deflater(compression, true);
   8:         }

View Full Code Here

Method Details

end

public void end()
Closes the decompressor and discards any unprocessed input. This method should be called when the decompressor is no longer being used, but will also be called automatically by the finalize() method. Once this method is called, the behavior of the Inflater object is undefined.
Usages and Demos :

View More Examples of end()
   1: import java.util.logging.Logger;
   2: import java.util.zip.Inflater; 
   3: import java.util.zip.DataFormatException;
   4:         ...
   5:         byte[] result =  new byte[Math.max(inPacket.length()*10+300, DonkeyPacketConstants.BLOCKSIZE + 30)];
   6:         Inflater decompresser = new Inflater();
   7:         ByteBuffer body = inPacket.getBuffer();
   8:         ...
   9:             int resultLength = decompresser.inflate(result);
  10:             decompresser.end();
  11:             DonkeyPacket uncompressedPacket = new DonkeyPacket(6 + resultLength);

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     private WriteBufferChannel SOURCE = new WriteBufferChannel(WRITER);
   6:     private Inflater INFLATER = new Inflater();
   7: 
   8:         ...
   9:     public void tearDown() {
  10:         DEFLATER.end();
  11:         ...
  12:         INFLATER.end();

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:   private PushbackInputStream _in;
   6:   private Inflater _inflater;
   7: 
   8:         ...
   9: 
  10:     _inflater = new Inflater(true);
  11:     _crc = new CRC32();
  12:         ...
  13:   {
  14:     _inflater.end();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:   {
   6:     Inflater inflater = new Inflater();
   7:     inflater.setInput( data, offset, length );
   8:         ...
   9:     int resultLength = inflater.inflate( result );
  10:     inflater.end();
  11:     byte[] retval = new byte[ resultLength ];

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:         
   6:         Inflater decompresser = new Inflater();
   7:         try {
   8:         ...
   9:             } finally {
  10:                 decompresser.end();
  11:             }

View Full Code Here

finalize

protected void finalize()
Closes the decompressor when garbage is collected.
Overrides:
finalize in interface Object

finished

public boolean finished()
Returns true if the end of the compressed data stream has been reached.
Returns:
true if the end of the compressed data stream has been reached
Usages and Demos :

View More Examples of finished()
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:          Inflater inflater = new Inflater();
   7:          inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9:          inflater.finished();
  10:          

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:             Inflater inflater = new Inflater();
   7:             inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9:             inflater.finished();

View Full Code Here
   1: import java.util.Random;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:         byte [] payload = resp[0].getPayload();
   6:         Inflater i = new Inflater();
   7:         i.setInput(payload);
   8:         ...
   9:         i.finished();
  10:         byte [] uncompressed = new byte[1024];
  11:         ...
  12:         i.setInput(payload);
  13:         i.finished();

View Full Code Here
   1: import java.util.zip.DeflaterOutputStream;
   2: import java.util.zip.Inflater;
   3: import java.util.zip.ZipEntry;
   4:         ...
   5:         
   6:         Inflater inflater = new Inflater();
   7:         inflater.setInput(compressedBytes);
   8:         ...
   9:         inflater.finished();
  10:         

View Full Code Here
   1: import java.util.Map;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:         
   6:         Inflater in = new Inflater();
   7:         in.setInput(data, 31, data.length - 31);
   8:         ...
   9:         in.finished();
  10:         byte [] inflated = new byte[60000];

View Full Code Here

getAdler

public int getAdler()
Returns the ADLER-32 value of the uncompressed data.
Returns:
the ADLER-32 value of the uncompressed data

getBytesRead

public long getBytesRead()
Returns the total number of compressed bytes input so far.
Returns:
the total (non-negative) number of compressed bytes input so far

getBytesWritten

public long getBytesWritten()
Returns the total number of uncompressed bytes output so far.
Returns:
the total (non-negative) number of uncompressed bytes output so far

getRemaining

public int getRemaining()
Returns the total number of bytes remaining in the input buffer. This can be used to find out what bytes still remain in the input buffer after decompression has finished.
Returns:
the total number of bytes remaining in the input buffer
Usages and Demos :

View More Examples of getRemaining()
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:   private PushbackInputStream _in;
   6:   private Inflater _inflater;
   7: 
   8:         ...
   9: 
  10:     _inflater = new Inflater(true);
  11:     _crc = new CRC32();
  12:         ...
  13:         if (_inflater.finished()) {
  14:           int remaining = _inflater.getRemaining();

View Full Code Here

getTotalIn

public int getTotalIn()
Returns the total number of compressed bytes input so far.

Since the number of bytes may be greater than Integer.MAX_VALUE, the getBytesRead() method is now the preferred means of obtaining this information.

Returns:
the total number of compressed bytes input so far
Usages and Demos :

View More Examples of getTotalIn()
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:     private final Inflater inflater;
   7: 
   8:         ...
   9:         try {
  10:             return deflater.getTotalIn();
  11:         } catch (NullPointerException npe) {
  12:         ...
  13:         try {
  14:             return inflater.getTotalIn();

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:     private InputStream inStream;
   6:     private Inflater inflater; 
   7: 
   8:         ...
   9:         {
  10:             totalIn = inflater.getTotalIn();
  11:         }
  12:         ...
  13:         {
  14:             totalIn = inflater.getTotalIn();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     
   6:     private Inflater _inflater;
   7:     
   8:         ...
   9:             if(isReadDeflated()) {
  10:                 _inflater = new Inflater();
  11:                 _in = new UncompressingInputStream(_in, _inflater);
  12:         ...
  13:             if(isReadDeflated()) {
  14:                 pCompressed = _inflater.getTotalIn();

View Full Code Here

getTotalOut

public int getTotalOut()
Returns the total number of uncompressed bytes output so far.

Since the number of bytes may be greater than Integer.MAX_VALUE, the getBytesWritten() method is now the preferred means of obtaining this information.

Returns:
the total number of uncompressed bytes output so far
Usages and Demos :

View More Examples of getTotalOut()
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:     private final Inflater inflater;
   7: 
   8:         ...
   9:         try {
  10:             return deflater.getTotalOut();
  11:         } catch (NullPointerException npe) {
  12:         ...
  13:         try {
  14:             return inflater.getTotalOut();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     
   6:     private Inflater _inflater;
   7:     
   8:         ...
   9:             if(isReadDeflated()) {
  10:                 _inflater = new Inflater();
  11:                 _in = new UncompressingInputStream(_in, _inflater);
  12:         ...
  13:                 pCompressed = _inflater.getTotalIn();
  14:                 pUncompressed = _inflater.getTotalOut();

View Full Code Here

inflate

public int inflate(byte[] b)
            throws DataFormatException
Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the later case, getAdler() can be used to get the Adler-32 value of the dictionary required.
Parameters:
b - the buffer for the uncompressed data
Returns:
the actual number of uncompressed bytes
Throws:
DataFormatException - if the compressed data format is invalid
Usages and Demos :

View More Examples of inflate(byte[] b)
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:          Inflater inflater = new Inflater();
   7:          inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9:          byte[] out = new byte[uncompressedSize];
  10:          inflater.inflate(out);
  11:          

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:             Inflater inflater = new Inflater();
   7:             inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9:             byte[] out = new byte[uncompressedSize];
  10:             inflater.inflate(out);

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:   private Inflater decompressor;
   7: 
   8:         ...
   9:     else
  10:       decompressor = new Inflater();
  11:   }
  12:         ...
  13:           {
  14:             len = decompressor.inflate(zlibBuffer);

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     Deflater[] deflater_pool=null;
   6:     Inflater[] inflater_pool=null;
   7: 
   8:         ...
   9:                 if(log.isTraceEnabled())
  10:                     log.trace("compressed payload from " + length + " bytes to " + compressed_size + " bytes (inflater #" +
  11:                     tmp_index + ")");
  12:         ...
  13:                         try {
  14:                             inflater.inflate(uncompressed_payload);

View Full Code Here
   1: import java.util.Random;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:         byte [] payload = resp[0].getPayload();
   6:         Inflater i = new Inflater();
   7:         i.setInput(payload);
   8:         ...
   9:         byte [] uncompressed = new byte[1024];
  10:         i.inflate(uncompressed);
  11:         Map<String,Object> o = (Map<String,Object>) Token.parse(uncompressed);
  12:         ...
  13:         byte [] uncompressed = new byte[1024];
  14:         i.inflate(uncompressed);

View Full Code Here

inflate

public int inflate(byte[] b,
                   int off,
                   int len)
            throws DataFormatException
Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. A return value of 0 indicates that needsInput() or needsDictionary() should be called in order to determine if more input data or a preset dictionary is required. In the later case, getAdler() can be used to get the Adler-32 value of the dictionary required.
Parameters:
b - the buffer for the uncompressed data
off - the start offset of the data
len - the maximum number of uncompressed bytes
Returns:
the actual number of uncompressed bytes
Throws:
DataFormatException - if the compressed data format is invalid
Usages and Demos :

View More Examples of inflate(byte[] b,int off,int len)
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
   6:     Inflater inflater = new Inflater();
   7:     byte count_expected = -1;
   8:         ...
   9:             try {
  10:                 len = inflater.inflate(unpack, 1, unpack.length - 1);
  11:             } catch (DataFormatException e) {

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:   private PushbackInputStream _in;
   6:   private Inflater _inflater;
   7: 
   8:         ...
   9: 
  10:     _inflater = new Inflater(true);
  11:     _crc = new CRC32();
  12:         ...
  13: 
  14:        sublen = _inflater.inflate(b, off + length, len - length);

View Full Code Here
   1: 
   2: import java.util.zip.Inflater;
   3: import java.util.zip.DataFormatException;
   4:         ...
   5:   private final int stride;
   6:   private Inflater inflater;
   7:   private boolean readFilter;
   8:         ...
   9:       {
  10:     return inflater.inflate( buf, offset, buf.length - offset);
  11:       }

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:     try {
   6:       Inflater inflater = new Inflater(true);
   7:       StringValue sb = env.createBinaryBuilder();
   8:         ...
   9:           int inflatedLength;
  10:           while ((inflatedLength = inflater.inflate(buffer, 0, sublen)) > 0) {
  11:             sb.append(buffer, 0, inflatedLength);

View Full Code Here
   1:   int zlibBufLen = 0;
   2:   Inflater zlibInflater;
   3: 
   4:         ...
   5:   final static int tightZlibBufferSize = 512;
   6:   Inflater[] tightInflaters;
   7: 
   8:         ...
   9: 
  10:     tightInflaters = new Inflater[4];
  11: 
  12:         ...
  13:       for (int dy = y; dy < y + h; dy++) {
  14:     zlibInflater.inflate(pixels8, dy * rfb.framebufferWidth + x, w);

View Full Code Here

needsDictionary

public boolean needsDictionary()
Returns true if a preset dictionary is needed for decompression.
Returns:
true if a preset dictionary is needed for decompression
See Also:
Inflater.setDictionary

needsInput

public boolean needsInput()
Returns true if no data remains in the input buffer. This can be used to determine if #setInput should be called in order to provide more input.
Returns:
true if no data remains in the input buffer
Usages and Demos :

View More Examples of needsInput()
   1:         boolean    is_first_line = true;
   2:         Inflater    infl = new Inflater();
   3: 
   4:         ...
   5:                             infl.setInput(data_buf, 0, (int) Math.min(data_buf.length, chunk_data_len - bytes_read));
   6:                             while ( !infl.needsInput() ) {
   7:                                 try {
   8:                                     inflate_cnt = infl.inflate(inflate_buf);

View Full Code Here

reset

public void reset()
Resets inflater so that a new set of input data can be processed.
Usages and Demos :

View More Examples of reset()
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:          Inflater inflater = new Inflater();
   7:          inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9:          
  10:          inflater.reset();         
  11:          return out;

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:             Inflater inflater = new Inflater();
   7:             inflater.setInput(input, 4, input.length - 4);
   8:         ...
   9: 
  10:             inflater.reset();
  11:             return out;

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     private int maxReadIndex;
   6:     private Inflater inflater;
   7: 
   8:         ...
   9:                 
  10:                 inflater.reset();
  11:                 inflater.setInput(compBuffer, 0, compSize);

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
   6:     Inflater inflater = new Inflater();
   7:     byte count_expected = -1;
   8:         ...
   9:         } else {
  10:             inflater.reset();
  11:             inflater.setInput(buffer, 1, len);

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     Deflater[] deflater_pool=null;
   6:     Inflater[] inflater_pool=null;
   7: 
   8:         ...
   9:                 synchronized(deflater) {
  10:                     deflater.reset();
  11:                     deflater.setInput(payload, msg.getOffset(), length);
  12:         ...
  13:                 if(log.isTraceEnabled())
  14:                     log.trace("compressed payload from " + length + " bytes to " + compressed_size + " bytes (inflater #" +

View Full Code Here

setDictionary

public void setDictionary(byte[] b)
Sets the preset dictionary to the given array of bytes. Should be called when inflate() returns 0 and needsDictionary() returns true indicating that a preset dictionary is required. The method getAdler() can be used to get the Adler-32 value of the dictionary needed.
Parameters:
b - the dictionary data bytes

setDictionary

public void setDictionary(byte[] b,
                          int off,
                          int len)
Sets the preset dictionary to the given array of bytes. Should be called when inflate() returns 0 and needsDictionary() returns true indicating that a preset dictionary is required. The method getAdler() can be used to get the Adler-32 value of the dictionary needed.
Parameters:
b - the dictionary data bytes
off - the start offset of the data
len - the length of the data

setInput

public void setInput(byte[] b)
Sets input data for decompression. Should be called whenever needsInput() returns true indicating that more input data is required.
Parameters:
b - the input data bytes
See Also:
needsInput()
Usages and Demos :

View More Examples of setInput(byte[] b)
   1: 
   2: import java.util.zip.Inflater;
   3: import java.util.zip.Deflater;
   4:         ...
   5: 
   6:   public void feedToInflater( Inflater inf ) 
   7:   {
   8:         ...
   9:     inf.setInput( data );
  10:   }

View Full Code Here
   1: import java.util.logging.Logger;
   2: import java.util.zip.Inflater; 
   3: import java.util.zip.DataFormatException;
   4:         ...
   5:         byte[] result =  new byte[Math.max(inPacket.length()*10+300, DonkeyPacketConstants.BLOCKSIZE + 30)];
   6:         Inflater decompresser = new Inflater();
   7:         ByteBuffer body = inPacket.getBuffer();
   8:         ...
   9:         body.get(compressedData);
  10:         decompresser.setInput(compressedData);
  11:         try {

View Full Code Here
   1: import java.nio.channels.ReadableByteChannel;
   2: import java.util.zip.Inflater;
   3: import java.util.zip.DataFormatException;
   4:         ...
   5:     
   6:     public InflaterReader(Inflater inflater) {
   7:         this(null, inflater);
   8:         ...
   9:                     
  10:                     inflater.setInput(data.array(), 0, data.position());
  11:                     data.clear();

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     
   6:     public InflaterReader(Inflater inflater) {
   7:         this(null, inflater);
   8:         ...
   9:                     
  10:                     inflater.setInput(data.array(), 0, data.position());
  11:                     data.clear();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     private WriteBufferChannel SOURCE = new WriteBufferChannel(WRITER);
   6:     private Inflater INFLATER = new Inflater();
   7: 
   8:         ...
   9:     private byte[] inflate(ByteBuffer data) throws Exception {
  10:         INFLATER.setInput(data.array(), 0, data.limit());
  11:         byte[] buf = new byte[512];

View Full Code Here

setInput

public void setInput(byte[] b,
                     int off,
                     int len)
Sets input data for decompression. Should be called whenever needsInput() returns true indicating that more input data is required.
Parameters:
b - the input data bytes
off - the start offset of the input data
len - the length of the input data
See Also:
needsInput()
Usages and Demos :

View More Examples of setInput(byte[] b,int off,int len)
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:       Deflater deflater = new Deflater(compressionLevel);
   6:       deflater.setInput(input, 0, input.length);
   7:       deflater.finish();
   8:         ...
   9: 
  10:          Inflater inflater = new Inflater();
  11:         ...
  12:          inflater.setInput(input, 4, input.length - 4);

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:         Deflater deflater = new Deflater(compressionLevel);
   6:         deflater.setInput(input, 0, input.length);
   7:         deflater.finish();
   8:         ...
   9: 
  10:             Inflater inflater = new Inflater();
  11:         ...
  12:             inflater.setInput(input, 4, input.length - 4);

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     private int maxReadIndex;
   6:     private Inflater inflater;
   7: 
   8:         ...
   9:                 inflater.reset();
  10:                 inflater.setInput(compBuffer, 0, compSize);
  11:                 

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5: 
   6:   private Inflater decompressor;
   7: 
   8:         ...
   9:     else
  10:       decompressor = new Inflater();
  11:   }
  12:         ...
  13:       {
  14:         compressor.setInput(in, offset, length);

View Full Code Here
   1: import java.util.zip.DataFormatException;
   2: import java.util.zip.Inflater;
   3: 
   4:         ...
   5:     DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
   6:     Inflater inflater = new Inflater();
   7:     byte count_expected = -1;
   8:         ...
   9:             inflater.reset();
  10:             inflater.setInput(buffer, 1, len);
  11:             try {

View Full Code Here