简体   繁体   English

jar文件夹中的资源列表?

[英]List of resources in a folder of jar file?

As usually I read resources from jar file as following: 通常我从jar文件中读取资源如下:

getClassLoader().getResource(pTextPath + "/" + pLang +".xml");

I need to read all resources with certain name from known folder in jar file. 我需要从jar文件中的已知文件夹中读取具有特定名称的所有资源。 Eg read *.xml from 例如,阅读* .xml

addon/resources/texts 插件/资源/文

Could I somehow get from jar files list of resources according to path and name template? 我可以根据路径和名称模板以某种方式从jar文件列表中获取资源吗?

UPDATE: Exact duplication of Get a list of resources from classpath directory Please close the question. 更新:完全重复从类路径目录获取资源列表请关闭问题。

CodeSource src = MyClass.class.getProtectionDomain().getCodeSource();
if (src != null) {
  URL jar = src.getLocation();
ZipInputStream zip = new ZipInputStream(jar.openStream());
/* Now examine the ZIP file entries to find those you care about. */
 ...
} 
else {
   /* Fail... */
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 列出JAR资源文件夹中所有子目录的名称 - List the names of all subdirectories in resources folder of a JAR 如何在 jar 文件中包含资源文件夹 - How to include the resources folder in a jar file 在 JAR 文件中获取 src 文件夹之外的资源 - Getting resources outside of src folder in a JAR file 如何播放 Jar 文件中资源文件夹中的 MP3 文件? - How to play MP3 files that are in the resources folder in a Jar file? FileNotFoundException启动jar-在资源文件夹中看不到文件 - FileNotFoundException starting jar - can't see file in resources folder 从可运行jar的资源文件夹中加载docx文件 - Loading docx file from resources folder in runnable jar 访问位于src文件夹之外的jar文件中的资源 - Accessing resources in a jar file that are located outside the src folder 将 JAR 文件从内部资源复制到临时文件夹 - Copy JAR file from inside resources to temp folder 制作可运行的jar文件后,如何在运行时从资源子文件夹中获取所有图像列表 - how to get all images list from resources sub folder in run time , after making run able jar file java,加载资源失败:无法解析文件:/my-jar.jar!/folder/my-file - java, loading of resources fails: unable to resolve file:/my-jar.jar!/folder/my-file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM