繁体   English   中英

jar文件夹中的资源列表?

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

通常我从jar文件中读取资源如下:

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

我需要从jar文件中的已知文件夹中读取具有特定名称的所有资源。 例如,阅读* .xml

插件/资源/文

我可以根据路径和名称模板以某种方式从jar文件列表中获取资源吗?

更新:完全重复从类路径目录获取资源列表请关闭问题。

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.

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