Java Is Jar File isJarFile(File file)

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

Description

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

License

Open Source License

Parameter

Parameter Description
file a parameter

Return

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

Declaration

public static boolean isJarFile(File file) 

Method Source Code

//package com.java2s;
/**/*www.  j  a va2s  . c  o m*/
 *  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 {
    private static final String JAR_EXTENSION = ".jar";

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

Related

  1. isJar(File file)
  2. isJar(final File element)
  3. isJar(InputStream is)
  4. isJar(String file)
  5. isJarFile(File f)
  6. isJarFile(File jar)