Java Decompress Byte Array decompress(byte[] compressed)

Here you can find the source of decompress(byte[] compressed)

Description

decompress

License

Open Source License

Declaration

public static String decompress(byte[] compressed) 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 {
    public static String decompress(byte[] compressed) throws IOException {
        final int BUFFER_SIZE = 32;
        ByteArrayInputStream is = new ByteArrayInputStream(compressed);
        GZIPInputStream gis = new GZIPInputStream(is, BUFFER_SIZE);
        StringBuilder string = new StringBuilder();
        byte[] data = new byte[BUFFER_SIZE];
        int bytesRead;
        while ((bytesRead = gis.read(data)) != -1) {
            string.append(new String(data, 0, bytesRead));
        }//from  w w  w .ja  va2s.co m
        gis.close();
        is.close();
        return string.toString();
    }
}

Related

  1. decompress(byte[] compressed)
  2. decompress(byte[] compressed)
  3. decompress(byte[] compressed)
  4. decompress(byte[] compressed)
  5. decompress(byte[] compressed)
  6. decompress(byte[] compressedData)
  7. decompress(byte[] compressedData)
  8. decompress(byte[] compressedData, int off, int len)
  9. decompress(byte[] data)