Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;

public class Main {
    public static String decompress(byte[] bytes) {
        if (bytes == null || bytes.length == 0) {
            return "";
        }
        String outStr = "";
        try {
            final GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
            final BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
            String line;
            while ((line = bf.readLine()) != null) {
                outStr += line;
            }
            bf.close();
        } catch (final IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return outStr;
    }
}