Here you can find the source of isGZip(BufferedInputStream instream)
Parameter | Description |
---|---|
instream | the BufferedInputStream to test. |
public static boolean isGZip(BufferedInputStream instream)
//package com.java2s; import java.io.BufferedInputStream; public class Main { /**/*from w w w .jav a2 s.c o m*/ * Test for GZIP stream signature. * * @param instream the BufferedInputStream to test. * @return true if input stream is gzip. */ public static boolean isGZip(BufferedInputStream instream) { instream.mark(2); byte[] b = new byte[2]; try { instream.read(b, 0, 2); } catch (Exception ex) { throw new RuntimeException("Couldn't read header from stream ", ex); } try { instream.reset(); } catch (Exception ex) { throw new RuntimeException("Couldn't reset stream ", ex); } return (b[0] == 31 && b[1] == -117); } }