Java examples for File Path IO:Zip File
is Gzip File by its content
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; public class Main { public static void main(String[] argv) throws Exception { File f = new File("Main.java"); System.out.println(isGzip(f)); }/*from w ww .ja va 2s . c o m*/ public static boolean isGzip(final File f) throws IOException { FileInputStream fis; boolean returnValue = false; fis = new FileInputStream(f); try { new GZIPInputStream(fis); returnValue = true; } catch (final IOException io) { // If we got here the file is readable but not in GZIP format // throw new RuntimeException(io); } finally { if (fis != null) { fis.close(); } } return returnValue; } }