Created
November 7, 2019 01:15
-
-
Save perry14/2eaabfa47cfd990691131417c1dfa5b1 to your computer and use it in GitHub Desktop.
获取jar包中的class名
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.util.Enumeration; | |
| import java.util.jar.JarEntry; | |
| import java.util.jar.JarFile; | |
| public class Main { | |
| public static void main(String[] args) throws IOException { | |
| // 项目中jar包所在物理路径 | |
| String jarName = "/Users/admin/src/test.jar"; | |
| JarFile jarFile = new JarFile(jarName); | |
| Enumeration<JarEntry> entrys = jarFile.entries(); | |
| while (entrys.hasMoreElements()) { | |
| JarEntry jarEntry = entrys.nextElement(); | |
| System.out.println(jarEntry.getName()); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment