Here you can find the source of isGZipped(final File f)
public static boolean isGZipped(final File f) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static boolean isGZipped(final File f) throws IOException { return isGZipped(new FileInputStream(f)); }/* w w w.ja v a 2s . co m*/ public static boolean isGZipped(final InputStream s) throws IOException { try { final byte[] toRead = new byte[2]; final int readBytes = s.read(toRead); if (readBytes < 2) { return false; } final byte b1 = (byte) 0x1f; final byte b2 = (byte) 0x8b; return (toRead[0] == b1 && toRead[1] == b2); } finally { s.close(); } } }