I just made a program, which iterates through a jar file, and prints out all of the qualified path names for each .class file
My code looks like the following:
public static ArrayList<String> getClassNames(String jarName) {
ArrayList<String> CorbaClasses = new ArrayList<String>();
System.out.println("Jar " + jarName );
try {
JarInputStream jarFile = new JarInputStream(new FileInputStream(
jarName));
JarEntry jarEntry;
while (true) {
jarEntry = jarFile.getNextJarEntry();
if (jarEntry == null) {
break;
}
if (jarEntry.getName().endsWith(".class")) {
System.out.println("Found "
+ jarEntry.getName().replaceAll("/", "\\.").replace(".class", ""));
CorbaClasses.add(jarEntry.getName().replaceAll("/", "\\."));
jarFile.close();
}
}
jarFile.close();
} catch (Exception e) {
e.printStackTrace();
}
return CorbaClasses;
}
What I need now is not to iterate only through one jar file, but to iterate through a bunch of folders, where in each folder there is a jar file, that I need to print out the path names of the class files.
How can i do that?