JAVA 在包里搜索所有的类(二)

2014-11-24 03:00:45 · 作者: · 浏览: 8
th);
for (File file : dir.listFiles()) {
if (file.isFile()) {
String clsName = file.getName();
clsName = pkgName + "."
+ clsName.substring(0, clsName.length() - 6);
ret.add(clsName);
}
}
} else {
FileInputStream fis = new FileInputStream(classPath);
JarInputStream jis = new JarInputStream(fis, false);
JarEntry e = null;
while ((e = jis.getNextJarEntry()) != null) {
String eName = e.getName();
if (eName.startsWith(rPath) && !eName.endsWith("/")) {
ret.add(eName.replace('/', '.').substring(0,
eName.length() - 6));
}
jis.closeEntry();
}
jis.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}


return ret;
}
}


ok = .:. =