Java String Decompress decompress(String str)

Here you can find the source of decompress(String str)

Description

decompress

License

Open Source License

Declaration

public static String decompress(String str) 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(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return str;
        }/*w w  w .j  a va2 s .co  m*/
        //        System.out.println("Input String length : " + str.length());
        GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(str.getBytes("ISO-8859-1")));
        BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "ISO-8859-1"));
        String outStr = "";
        String line;
        while ((line = bf.readLine()) != null) {
            outStr += line;
        }
        //        System.out.println("Output String lenght : " + outStr.length());
        return outStr;
    }
}