jar文件夹中的资源列表?
通常我从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... */ }