Java Zip File Check isZipFile(String path)

Here you can find the source of isZipFile(String path)

Description

is Zip File

License

Open Source License

Declaration

public static boolean isZipFile(String path) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Chen Chao(cnfree2000@hotmail.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w w  w  .  java2s  .co  m
 *  Chen Chao  - initial API and implementation
 *******************************************************************************/

import java.io.IOException;

import java.util.zip.ZipFile;

public class Main {
    public static boolean isZipFile(String path) {
        if (path == null)
            return false;
        try {
            new ZipFile(path).close();
            ;
            return true;
        } catch (IOException e) {
            return false;
        }
    }
}

Related

  1. isZipFile(File file)
  2. isZipFile(InputStream stream)
  3. isZipFile(java.io.File file)
  4. isZipFile(String fileName)
  5. isZipFile(String fileName)
  6. isZipOrJarArchive(File file)
  7. isZipped(File f)
  8. isZipped(File file)
  9. isZipped(final File file)