net.onedaybeard.ecs.util.ClassFinder Maven / Gradle / Ivy
package net.onedaybeard.ecs.util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public final class ClassFinder {
private ClassFinder() {}
public static List find(String root) {
return find(new File(root));
}
public static List find(File root) {
if (!root.isDirectory())
throw new IllegalAccessError(root + " must be a folder.");
List klazzes = new ArrayList();
addFiles(klazzes, root);
return klazzes;
}
private static void addFiles(List files, File folder) {
for (File f : folder.listFiles()) {
if (f.isFile() && f.getName().endsWith(".class"))
files.add(f);
else if (f.isDirectory())
addFiles(files, f);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy