Java Byte Array Uncompress uncompress(byte[] b)

Here you can find the source of uncompress(byte[] b)

Description

uncompress

License

Open Source License

Declaration

public static String uncompress(byte[] b) throws IOException 

Method Source Code


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

import java.io.*;
import java.util.zip.GZIPInputStream;

public class Main {
    private static final int BUFFER_SIZE = 1024;

    public static String uncompress(byte[] b) throws IOException {
        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
            try (GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(b), BUFFER_SIZE)) {
                byte[] buffer = new byte[BUFFER_SIZE];
                int n;
                while ((n = gzip.read(buffer)) >= 0) {
                    out.write(buffer, 0, n);
                }//  w w  w. java  2  s  .  co  m
            }
            return out.toString();
        }
    }
}

Related

  1. uncompress(byte[] data)
  2. uncompress(byte[] gzData, String charset)
  3. uncompress(byte[] input, int uncompr_len)
  4. uncompress(final byte[] buffer)