Java Zip File Check isZip(File file)

Here you can find the source of isZip(File file)

Description

is Zip

License

Open Source License

Declaration

public static boolean isZip(File file) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.util.zip.ZipInputStream;

public class Main {
    public static boolean isZip(File file) {
        try (FileInputStream inputStream = new FileInputStream(file)) {
            return new ZipInputStream(inputStream).getNextEntry() != null;
        } catch (IOException e) {
            throw new RuntimeException("Problem to check if file " + file.getPath() + " is a zip", e);
        }/*from  w  w  w  .  j ava2  s  .  c om*/
    }
}

Related

  1. isZip(File candidate)
  2. isZip(File f)
  3. isZip(File file)
  4. isZip(File file)
  5. isZip(File file)
  6. isZip(File zip)
  7. isZip64EndOfCentralDirectoryLocatorPresent(RandomAccessFile zip, long zipEndOfCentralDirectoryPosition)
  8. isZipContainsEntry(File zip, String relativePath)
  9. isZipEntryPackage(String str)