Java Zip File Check isZipFile(File f)

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

Description

is Zip File

License

Open Source License

Return

true if file represents an existing file with a zip extension

Declaration

public static boolean isZipFile(File f) 

Method Source Code


//package com.java2s;
/* *******************************************************************
 * Copyright (c) 1999-2000 Xerox Corporation. 
 * All rights reserved. //  w ww . j  a  v a 2  s. c om
 * 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: 
 *     Xerox/PARC     initial implementation 
 * ******************************************************************/

import java.io.File;

public class Main {
    /**
     * @return true if file represents an existing file with a zip extension
     */
    public static boolean isZipFile(File f) {
        String s = null;
        if ((null == f) || (null == (s = f.getPath()))) {
            return false;
        } else {
            return (f.canRead() && !f.isDirectory() && (s.endsWith(".zip") || (s.endsWith(".jar"))));
        }
    }
}

Related

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