A zip file system using jar:file:
URIs would be something like this:
URI uri = MainApp.class.getResource("/images/sprites").toURI();
Map<String, String> env = new HashMap<>();
try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {
//Path path = zipfs.getPath("/images/icons16");
for (Path path : zipfs.getRootDirectories()) {
Files.list(path.resolve("/images/sprites"))
.forEach(p -> System.out.println("* " + p));
}
}
Here I show getRootDirectories
to possibly iterate over all resources.
Using the Files.copy
one may copy them etcetera.
After comment of @MrPowerGamerBR:
The solution above deals with a jar. A more general solution, not exposing the jar character, is:
URI uri = MAinApp.class.getResource("/images/sprites").toURI();
Path dirPath = Paths.get(uri);
Files.list(dirPath)
.forEach(p -> System.out.println("* " + p));
(In fact one might even read lines from the directory itself, but this
is the correct abstraction, using Path.)