Source is a Java Maven project.
Java resources directory contains subdirectories that contain configuration files. Config files can be added and removed as a maintenance process. Names of files not suppose to be known.
How I can get a list of all files in a mentioned project "resources" directory?
There is a solution using Spring framework class PathMatchingResourcePatternResolver
, however this class requires Apache Commons Logging and when dependency added the project is getting set to java 1.7 source from 1.8 that breaks existing code compatibility.
Does java have a class that can list files of a mentioned folder, or java was never need it?
Update: Was able to resolve the issue with this solution (else condition //Run with IDE) https://stackoverflow.com/a/20073154/323128
path is a folder name inside "resources" directory.
You can use the JarFile class to interrogate the contents of JARs programmatically: https://docs.oracle.com/javase/7/docs/api/java/util/jar/JarFile.html.
Some examples: http://www.programcreek.com/java-api-examples/java.util.jar.JarFile
You can also use jar.exe from the JDK itself to interrogate JAR files. This command will show everything under the resources level from the root...
jar tf YourApplication.jar resources
The Guava ClassPath class may also be worth looking at: (https://github.com/google/guava/blob/master/guava/src/com/google/common/reflect/ClassPath.java).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments