I'm having trouble reaching a target folder "images" when my application is packaged as a JAR. I am not after getting a single file, what I want is a list of all the .jpg files in the "images" folder.
I've tried this:
URI uri = getClass().getClassLoader.getResource("images").toURI();
This returns: jar:file:/C:/test-1.0-SNAPSHOT.jar!/BOOT-INF/lib/core-1.0-SNAPSHOT.jar!/images
Then i tried to create a stream to iterate over the files like this:
FileSystem fs = FileSystems.newFilesSystem(uri, Collections.emptyMap());
Path p = fs.getPath("images");
Files.walk(p).forEach(path -> System.out.println(path));
This just gives med a FileNotFoundException.
So, how can I access the "images" folder inside my nested JARs?
EDIT: This is not duplicate of: How to list the files inside a JAR file?. I have tried every thing in there. The difference is that i have a JAR INSIDE another JAR, nested JARs. This is what is creating the issue i believe.