URL url = InternationalResouces.class.getProtectionDomain().getCodeSource().getLocation(); JarFile jarFile = new JarFile(url.getFile()); Enumeration<JarEntry> enumeration = jarFile.entries(); while (enumeration.hasMoreElements()) { JarEntry entry = enumeration.nextElement(); String entryName = entry.getName(); if (entryName.indexOf(path) != -1 && entryName.endsWith("properties")) { String[] pathGroup = entryName.split("/"); String fileName = pathGroup[pathGroup.length - 1]; String[] nameGroup = fileName.split("\\."); if (nameGroup.length != 2) { continue; } String realName = nameGroup[0]; String[] realNameGroup = realName.split("_"); if (realNameGroup.length != 2) { continue; } String country = realNameGroup[1]; Properties properties = new Properties(); properties.load(jarFile.getInputStream(entry)); LanguageStore store = new LanguageStore(); store.setCountry(country); store.setLanguageMap(properties); languageStore.add(store); } } jarFile.close();
遍历WEBINF下的jar包内的资源
最新推荐文章于 2023-06-16 17:41:28 发布