Java Gunzip File ungzip(byte[] bytes)

Here you can find the source of ungzip(byte[] bytes)

Description

ungzip

License

Open Source License

Declaration

public static String ungzip(byte[] bytes) throws Exception 

Method Source Code

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

import java.io.ByteArrayInputStream;

import java.io.InputStreamReader;

import java.io.StringWriter;

import java.nio.charset.StandardCharsets;

import java.util.zip.GZIPInputStream;

public class Main {
    public static String ungzip(byte[] bytes) throws Exception {
        InputStreamReader isr = new InputStreamReader(new GZIPInputStream(new ByteArrayInputStream(bytes)),
                StandardCharsets.UTF_8);
        StringWriter sw = new StringWriter();
        char[] chars = new char[1024];
        for (int len; (len = isr.read(chars)) > 0;) {
            sw.write(chars, 0, len);//from  ww  w. ja v a  2s  .co  m
        }
        return sw.toString();
    }
}

Related

  1. gunzip(String compressedStr)
  2. gunzip(String inFile, String outFile)
  3. gunzipFile(File baseDir, File gzFile)
  4. gunzipFile(File file_input, File dir_output)
  5. gunzipFile(File inputGZippedFile, File outputFile)