Java Utililty Methods Is Jar File

List of utility methods to do Is Jar File

Description

The list of methods to do Is Jar File are organized into topic(s).

Method

booleanisJarFile(File jar)
is Jar File
return jar.getName().endsWith(".jar");
booleanisJar(File file)
Test if a file looks like it contains a Jar
try {
    new JarFile(file);
    return true;
} catch (Exception e) {
return false;
booleanisJarFile(File f)
is Jar File
if (f != null) {
    if (f.getName().contains(".jar") || f.getAbsolutePath().contains(".jar")) {
        return true;
return false;
booleanisJar(final File element)
is Jar
return (element.isFile() && element.getName().endsWith(JAR_SUFFIX));
booleanisJarFile(File file)
Returns true if the given file is a jar file and false otherwise.
return file.isFile() && file.getName().toLowerCase().endsWith(JAR_EXTENSION);
booleanisJar(File file)
Is the file a JAR?
try {
    JarFile jarFile = new JarFile(file); 
    jarFile.close(); 
    return true;
} catch (IOException e) {
    return false;
booleanisJar(File file)
is Jar
return existsWithExtension(file, ".jar");
booleanisJar(InputStream is)
Check if this inputstream is a jar/zip
try {
    JarInputStream jis = new JarInputStream(is);
    if (jis.getNextEntry() != null) {
        return true;
} catch (IOException ioe) {
return false;
...
booleanisJar(String file)
is Jar
try {
    JarFile jar = new JarFile(file);
    JarEntry entry = jar.getJarEntry("META-INF/MANIFEST.MF");
    jar.close();
    return entry != null;
} catch (IOException e) {
    return false;