package net.sourceforge.javautil.classloader.util;
import java.util.List;
import net.sourceforge.javautil.classloader.impl.ClassInfo;
import net.sourceforge.javautil.classloader.impl.ClassSearchInfo;
import net.sourceforge.javautil.classloader.source.ClassSource;
import net.sourceforge.javautil.classloader.source.LibDirectoryClassSource;
import net.sourceforge.javautil.common.io.impl.SystemDirectory;
/**
* This will allow one to search for a resource using all the libraries found in a particular directory recursively.
*
* @author elponderador
* @author $Author$
* @version $Id$
*/
public class ResourceSearch {
/**
* The first argument should be the directory to search in.
* The second argument should be the resource name to search for.
*
* @param args Command line arguments
*/
public static void main (String[] args) {
if (args.length != 2) {
System.err.println("Please provide the library directory and the resource name to search for.");
} else {
System.out.println("Searching for " + args[1] + " in " + args[0]);
LibDirectoryClassSource lib = new LibDirectoryClassSource(new SystemDirectory(args[0]), true);
List<ClassSource> sources = lib.getAllNonCompositeSources();
for (ClassSource source : sources) {
for (String name : source.getResourceNames()) {
if (name.contains(args[1])) {
System.out.println("Found: " + name + " in " + source);
}
}
}
}
}
}