Java GZip InputStream Check isGzipStm(InputStream in)

Here you can find the source of isGzipStm(InputStream in)

Description

is Gzip Stm

License

Apache License

Declaration

static public final boolean isGzipStm(InputStream in)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

import java.util.zip.GZIPInputStream;

public class Main {

    static public final boolean isGzipStm(InputStream in)
            throws IOException {
        boolean ms = in.markSupported();
        if (ms)//from  ww w. ja  va2s .com
            in.mark(10);
        int b1 = in.read();
        int b2 = in.read();
        if (ms)
            in.reset();
        return ((b2 << 8 | b1) == GZIPInputStream.GZIP_MAGIC);
    }
}

Related

  1. isGZip(BufferedInputStream instream)
  2. isGZIPCompressed(InputStream in)
  3. isGZipped(InputStream in)
  4. isGZipped(InputStream in)