Java 迭代jar文件中的类
有人知道一个2-3行的解决方案,可以在某个Jar文件中迭代类吗 (我手里有一个java.net.URL的实例) 谢谢 以下是第一篇文章的代码片段:Java 迭代jar文件中的类,java,Java,有人知道一个2-3行的解决方案,可以在某个Jar文件中迭代类吗 (我手里有一个java.net.URL的实例) 谢谢 以下是第一篇文章的代码片段: ZipFile zip = new ZipFile(fileName); // Process the zip file. Close it when the block is exited. try { // Loop through the zip entries and print the name of each
ZipFile zip = new ZipFile(fileName);
// Process the zip file. Close it when the block is exited.
try {
// Loop through the zip entries and print the name of each one.
for (Enumeration list = zip.entries(); list.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) list.nextElement();
System.out.println(entry.getName());
}
}
finally {
zip.close();
}
jar-tf xyz.jar | grep类 。您可以从URL而不是代码使用的文件创建输入流