Here you can find the source of isGZipped(final File file)
public static boolean isGZipped(final File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.RandomAccessFile; import java.util.zip.GZIPInputStream; public class Main { public static boolean isGZipped(final File file) { // code taken from: http://stackoverflow.com/a/30507742/3094906 int magic = 0; try {//from w ww . ja v a 2s . co m RandomAccessFile raf = new RandomAccessFile(file, "r"); magic = raf.read() & 0xff | raf.read() << 8 & 0xff00; raf.close(); } catch (Throwable e) { e.printStackTrace(System.err); } return magic == GZIPInputStream.GZIP_MAGIC; } }