解决了jar包无法扫描问题

This commit is contained in:
Biubiu
2020-01-15 10:29:57 +08:00
parent 4e968bcd08
commit 3147d9f9b7
4 changed files with 125 additions and 86 deletions

View File

@@ -0,0 +1,29 @@
package cn.edu.scau.biubiusuisui.utils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class ClassUtilsTest {
public static void main(String[] args) {
JarFile jarFile = null;
try {
jarFile = new JarFile("/Users/Jack/test.jar");
} catch (IOException e) {
e.printStackTrace();
}
Enumeration<JarEntry> entrys = jarFile.entries();
List<String> classNames = new ArrayList<>();
while (entrys.hasMoreElements()) {
JarEntry jarEntry = entrys.nextElement();
classNames.add(jarEntry.getName());
}
classNames.forEach(System.out::println);
}
}