Java Jar File Find findJar(File dir)

Here you can find the source of findJar(File dir)

Description

find Jar

License

Open Source License

Declaration

private static File findJar(File dir) 

Method Source Code

//package com.java2s;
/**/*  ww w  .  j a v  a 2  s .  c o m*/
 * Copyright (c) 2010-2016 by the respective copyright holders.
 *
 * 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
 */

import java.io.File;

public class Main {
    private static File findJar(File dir) {

        if (dir == null || !dir.isDirectory()) {
            return null;
        }

        for (File file : dir.listFiles()) {
            if (file.isDirectory()) {
                File f = findJar(file);
                if (f != null) {
                    return f;
                }
            } else if (file.getName().trim().toLowerCase().endsWith(".jar")) {
                return file;
            }
        }

        return null;
    }
}

Related

  1. findContainingJar(Class clazz)
  2. findContainingJar(Class myClass, Map packagedClasses)
  3. findContainingJar(ClassLoader classLoader, String resourceName)
  4. findJar(Class klass)
  5. findJar(Class my_class)
  6. findJar(String nameRegexp)
  7. findJarContaining(Class c)
  8. findJarEntry(String entryName, JarInputStream jarFile)
  9. findJarFiles(String[] classPathLines)