Here you can find the source of decompressStream(InputStream input)
public static InputStream decompressStream(InputStream input) throws Exception
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.io.PushbackInputStream; import java.util.zip.GZIPInputStream; public class Main { public static InputStream decompressStream(InputStream input) throws Exception { PushbackInputStream pb = new PushbackInputStream(input, 2); //we need a pushbackstream to look ahead byte[] signature = new byte[2]; try {/*from w w w . j a v a 2 s. co m*/ pb.read(signature); //read the signature pb.unread(signature); //push back the signature to the stream } catch (Exception e) { } if (signature[0] == (byte) 0x1f && signature[1] == (byte) 0x8b) //check if matches standard gzip maguc number return new GZIPInputStream(pb); else return pb; } }