简体   繁体   中英

Directory list of JAR file within classpath

The typically method to reference a file contained with a JAR file is to use ClassLoader.getResource . Is there a way to get the contents of a directory within a JAR files (similar to java.io.File.listFiles() )? Note that the JAR file is within the classpath and its filename might not be known during runtime.

Basically I have a bunch of non-.class resource files within a directory. At runtime I need to load each resource file contained within a known directory.

有一个名为java.class.path的系统属性,它解析jar的路径,然后使用JarURLConnection类来执行所需的操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM