Java Zip File Check isZipFile(File file)

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

Description

Check whether the given file is a ZIP-file.

License

LGPL

Parameter

Parameter Description
file the file to check.

Return

True if the file is supposed to be a ZIP-file, false otherwise.

Declaration

public static boolean isZipFile(File file) 

Method Source Code

//package com.java2s;
/********************************************************************************
 *                                                                              *
 *  (c) Copyright 2010 Verizon Communications USA and The Open University UK    *
 *                                                                              *
 *  This software is freely distributed in accordance with                      *
 *  the GNU Lesser General Public (LGPL) license, version 3 or later            *
 *  as published by the Free Software Foundation.                               *
 *  For details see LGPL: http://www.fsf.org/licensing/licenses/lgpl.html       *
 *               and GPL: http://www.fsf.org/licensing/licenses/gpl-3.0.html    *
 *                                                                              *
 *  This software is provided by the copyright holders and contributors "as is" *
 *  and any express or implied warranties, including, but not limited to, the   *
 *  implied warranties of merchantability and fitness for a particular purpose  *
 *  are disclaimed. In no event shall the copyright owner or contributors be    *
 *  liable for any direct, indirect, incidental, special, exemplary, or         *
 *  consequential damages (including, but not limited to, procurement of        *
 *  substitute goods or services; loss of use, data, or profits; or business    *
 *  interruption) however caused and on any theory of liability, whether in     *
 *  contract, strict liability, or tort (including negligence or otherwise)     *
 *  arising in any way out of the use of this software, even if advised of the  *
 *  possibility of such damage.                                                 *
 *                                                                              *
 ********************************************************************************/

import java.io.File;

public class Main {
    /**/*from w  ww  .j  a  v a2  s. c  o  m*/
     * Check whether the given file is a ZIP-file.
     * @author Sebastian Ehrich
     * @param file the file to check.
     * @return <code>True</code> if the file is supposed to be
     * a ZIP-file, <code>false</code> otherwise.
     */
    public static boolean isZipFile(File file) {
        String fileName = file.getPath().toLowerCase();
        return (fileName.endsWith(".zip"));
    }
}

Related

  1. isZipFile(File file)
  2. isZipFile(File file)
  3. isZipFile(File file)
  4. isZipFile(File file)
  5. isZipFile(File file)
  6. isZipFile(File file)
  7. isZipFile(File file)
  8. isZipFile(File file)
  9. isZipFile(File file)