Here you can find the source of isGzipStm(InputStream in)
static public final boolean isGzipStm(InputStream in) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPInputStream; public class Main { static public final boolean isGzipStm(InputStream in) throws IOException { boolean ms = in.markSupported(); if (ms)//from ww w. ja va2s .com in.mark(10); int b1 = in.read(); int b2 = in.read(); if (ms) in.reset(); return ((b2 << 8 | b1) == GZIPInputStream.GZIP_MAGIC); } }