Java Zip File Check isZipFile(File file)

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

Description

Returns true if the given file is a zip file and false otherwise.

License

Open Source License

Parameter

Parameter Description
file a parameter

Return

true if the given file is a zip file and false otherwise.

Declaration

public static boolean isZipFile(File file) 

Method Source Code

//package com.java2s;
/**/*from  w ww.ja  va2s  .  c om*/
 *  Copyright (c) 2013-2016 Angelo ZERR.
 *  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:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */

import java.io.File;

public class Main {
    public static final String ZIP_EXTENSION = ".zip";

    /**
     * Returns true if the given file is a zip file and false otherwise.
     * 
     * @param file
     * @return true if the given file is a zip file and false otherwise.
     */
    public static boolean isZipFile(File file) {
        return file.isFile() && file.getName().toLowerCase().endsWith(ZIP_EXTENSION);
    }
}

Related

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