[英]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.