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