Java Utililty Methods Zip File Check

List of utility methods to do Zip File Check

Description

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

Method

booleanisZippedFile(File file)
Returns true if the input file is a zipped file.
return isGzipFile(file) || isZipFile(file) || isBZipFile(file) || isUnixCompressFile(file);
booleanisZipStream(ByteArrayInputStream input)
is Zip Stream
boolean isZip = true;
int length = ZIP_HEADER.length;
try {
    input.mark(length + 1);
    for (int i = 0; i < length; i++) {
        byte read = (byte) input.read();
        if (read != ZIP_HEADER[i]) {
            isZip = false;
...
booleanisZipStream(InputStream in)
The method to test if a input stream is a zip archive.
if (!in.markSupported()) {
    throw new IOException("The stream does not support mark.");
boolean isZip = true;
try {
    in.mark(MAGIC.length);
    for (int i = 0; i < MAGIC.length; i++) {
        if (MAGIC[i] != (byte) in.read()) {
...
booleanisZipValid(File file)
is Zip Valid
try (ZipFile zipFile = new ZipFile(file)) {
    return true;
} catch (IOException ioe) {
    return false;
booleanisZipValid(final File zip)
Check if the given zip file is valid.
ZipFile zipfile = null;
try {
    zipfile = new ZipFile(zip);
    return true;
} catch (ZipException e) {
    return false;
} catch (IOException e) {
    return false;
...