📜  如何在java代码示例中打印所有包

📅  最后修改于: 2022-03-11 14:52:08.741000             🧑  作者: Mango

代码示例1
final ClassLoader loader = Thread.currentThread().getContextClassLoader();

for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
  if (info.getName().startsWith("my.package.")) {
    final Class clazz = info.load();
    // do something with your clazz
  }
}