See Also: Inflater Members
This class decompresses data that was compressed using the DEFLATE algorithm (see ).
It is usually more convenient to use Java.Util.Zip.InflaterInputStream.
To decompress an in-memory byte[] to another in-memory byte[] manually:
java Example
byte[] compressedBytes = ... int decompressedByteCount = ... // From your format's metadata. Inflater inflater = new Inflater(); inflater.setInput(compressedBytes, 0, compressedBytes.length); byte[] decompressedBytes = new byte[decompressedByteCount]; if (inflater.inflate(decompressedBytes) != decompressedByteCount) { throw new AssertionError(); } inflater.end();
In situations where you don't have all the input in one array (or have so much input that you want to feed it to the inflater in chunks), it's possible to call Inflater.SetInput(Byte[]) repeatedly, but you're much better off using Java.Util.Zip.InflaterInputStream to handle all this for you.
If you don't know how big the decompressed data will be, you can call Inflater.Inflate(Byte[]) repeatedly on a temporary buffer, copying the bytes to a Java.IO.ByteArrayOutputStream, but this is probably another sign you'd be better off using Java.Util.Zip.InflaterInputStream.