Here you can find the source of isGZipped(InputStream in)
Parameter | Description |
---|---|
in | a parameter |
public static boolean isGZipped(InputStream in)
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPInputStream; public class Main { /**/* ww w . j a v a 2 s. co m*/ * Checks if an input stream is gzipped. * * @param in * @return */ public static boolean isGZipped(InputStream in) { int magic = 0; try { if (!in.markSupported()) { in = new BufferedInputStream(in); } in.mark(2); try { magic = in.read() & 0xff | ((in.read() << 8) & 0xff00); in.reset(); } catch (IOException e) { e.printStackTrace(System.err); return false; } } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(System.err); return false; } } return magic == GZIPInputStream.GZIP_MAGIC; } }