Java Utililty Methods GZip File Check

List of utility methods to do GZip File Check

Description

The list of methods to do GZip File Check are organized into topic(s).

Method

booleanisGZipped(final File f)
is G Zipped
return isGZipped(new FileInputStream(f));
booleanisGzipped(final File file)
Checks if the file is gzipped.
int magic = 0;
final RandomAccessFile raf = new RandomAccessFile(file, "r");
magic = raf.read() & 0xff | ((raf.read() << 8) & 0xff00);
raf.close();
return magic == GZIPInputStream.GZIP_MAGIC;
booleanisGZipped(final File file)
is G Zipped
int magic = 0;
try {
    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;
booleanisGzipped(String fileName)
Tests if a file has been compressed using gzip.
return isGzipped(new File(fileName));
booleanisGZipped(String name)
Returns true if file is in GZip format and false if it is not.
int n = 0;
File file = null;
RandomAccessFile raf = null;
try {
    try {
        file = new File(name);
        if (!file.exists()) {
            return false;
...