Here you can find the source of isJar(File file)
Parameter | Description |
---|---|
file | a parameter |
public static boolean isJar(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.util.jar.JarFile; public class Main { /**/*from w w w. j a va 2 s . c om*/ * Is the file a JAR? * * @param file * @return */ public static boolean isJar(File file) { //TODO: bad style to write code that depends on exceptions try { JarFile jarFile = new JarFile(file); // throws IOException if not a jar file jarFile.close(); // don't rely on finalize to close return true; } catch (IOException e) { return false; } } }