Here you can find the source of isGzipped(File f)
public static boolean isGzipped(File f)
//package com.java2s; //License from project: Open Source License import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static boolean isGzipped(File f) { InputStream is = null;//from w w w . j a v a2 s. c o m try { is = new FileInputStream(f); byte[] signature = new byte[2]; int nread = is.read(signature); //read the gzip signature return nread == 2 && signature[0] == (byte) 0x1f && signature[1] == (byte) 0x8b; } catch (IOException e) { return false; } finally { closeSafely(is); } } private static void closeSafely(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { e.printStackTrace(); } } } }