java - 遍历 jar 文件中的类

标签 java

有人知道迭代某些 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/

相关文章:

java - 通过在 Eclipse 中突出显示自动搜索

java - 如何使用 void display() 在 java 中显示多个输入?

java - 如何将日期时间字符串转换为 "yyyy-MM-dd' T'HH :mm:ss. SSSSSSSSSZ"

java - Android 异步中的 NetworkOnMainThreadException

java - 简单的Java正则表达式匹配失败

java - 如何使用 Java 对字符串进行排序

java - 低计算java paintcomponent中的低fps

java - 获取JDBC连接失败;嵌套异常是 java.sql.SQLException : null

java - 如何在Java中获取文本文件的随机行?

java - 在 Websphere Application Server 8.5 上运行的 Web 应用程序中的字符编码