Java Decompress Byte Array decompress(byte[] data, int off, int len)

Here you can find the source of decompress(byte[] data, int off, int len)

Description

decompress

License

Open Source License

Declaration

public static byte[] decompress(byte[] data, int off, int len) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

import java.util.zip.Inflater;

public class Main {

    public static byte[] decompress(byte[] data, int off, int len) {

        byte[] output = null;

        Inflater decompresser = new Inflater();
        decompresser.reset();/*from   w w  w.  j a va  2s . c  o  m*/
        decompresser.setInput(data, off, len);

        ByteArrayOutputStream out = new ByteArrayOutputStream(data.length);
        try {
            byte[] result = new byte[1024];
            while (!decompresser.finished()) {
                int i = decompresser.inflate(result);
                out.write(result, 0, i);
            }
            output = out.toByteArray();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                out.close();
            } catch (Exception e) {
            }
            decompresser.end();
        }
        return output;
    }
}

Related

  1. decompress(byte[] data)
  2. decompress(byte[] data)
  3. decompress(byte[] data)
  4. decompress(byte[] data)
  5. decompress(byte[] data)
  6. decompress(byte[] data, int offset, int length)
  7. decompress(byte[] gzipped)
  8. decompress(byte[] in)
  9. decompress(byte[] input)