Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.io.*;

import java.util.zip.GZIPInputStream;

public class Main {
    /**
     * uncompress the xmlByteArray
     */
    public static byte[] uncompressByteArray(byte[] xmlByteArray) throws IOException {
        byte[] tmp = new byte[2048];
        int byteCount = 0;
        ByteArrayOutputStream uncompressedData = new ByteArrayOutputStream();
        GZIPInputStream gzipIS = new GZIPInputStream(new ByteArrayInputStream(xmlByteArray));

        while ((byteCount = gzipIS.read(tmp)) != -1) {
            uncompressedData.write(tmp, 0, byteCount);
        }

        return uncompressedData.toByteArray();
    }
}