gpt4 book ai didi

java - 遍历 jar 文件中的类

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:29:04 27 4
gpt4 key购买 nike

有人知道迭代某些 Jar 文件中的类的 2-3 行解决方案吗?

(我手里有一个 java.net.URL 的实例)

谢谢

最佳答案

Accessing zips and jars using Java Part 1

Accessing zips and jars using Java Part 2

这是第一篇文章的代码片段:

  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();
}

关于java - 遍历 jar 文件中的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2370867/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com