List of resources in the jar file folder?

As usual, I read the resources from the jar file as follows:

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

I need to read all resources with a specific name from a known folder in a jar file. For instance. read * .xml from

addon / resources / Texts

Is there any way to get files from the list of jar resource files according to the path and name pattern?

UPDATE: Exact Copy Get a list of resources from the pathpath directory . Close the question.

+6
source share
1 answer
 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... */ } 
+4
source

Source: https://habr.com/ru/post/900430/


All Articles