Java Byte Array Uncompress uncompress(byte[] input, int uncompr_len)

Here you can find the source of uncompress(byte[] input, int uncompr_len)

Description

uncompress

License

Open Source License

Declaration

private static byte[] uncompress(byte[] input, int uncompr_len) throws IOException, DataFormatException 

Method Source Code


//package com.java2s;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import java.util.zip.DataFormatException;

import java.util.zip.Inflater;

public class Main {
    private static byte[] uncompress(byte[] input, int uncompr_len) throws IOException, DataFormatException {
        Inflater decompressor = new Inflater();
        ByteArrayOutputStream bos = new ByteArrayOutputStream(uncompr_len);
        byte[] buf = new byte[uncompr_len];
        decompressor.setInput(input);// ww w .  ja va2s  .  c  om
        while (!decompressor.finished()) {
            int count = decompressor.inflate(buf);
            if (count <= 0) {
                break;
            }
            bos.write(buf, 0, count);
        }
        decompressor.end();
        return bos.toByteArray();
    }
}

Related

  1. uncompress(byte[] b)
  2. uncompress(byte[] data)
  3. uncompress(byte[] gzData, String charset)
  4. uncompress(final byte[] buffer)
  5. uncompress(final byte[] compressedData)
  6. uncompress(final byte[] src)
  7. uncompressByte(byte[] content)