How to list all files from the resources directory

Maxim

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.

ManoDestra

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to list all CSV files in a Windows Directory using C++?

From Dev

Python 2.7 How to list files in a directory AND all sub directories?

From Dev

Search and List all files from directory/subdirectories into ListBox

From Dev

How to load all files of a folder to a list of Resources in Spring?

From Dev

Android: How to list all the files in a directory in to an array?

From Dev

Cordova list all files from application directory (WWW)

From Dev

Cocos2d-x How to list all files from a resource directory

From Dev

How to retrieve a list of all files in the Working Directory

From Dev

How to list recently deleted files from a directory?

From Dev

How to get all the files from a directory in xslt

From Dev

How to move all files from current directory to upper directory?

From Dev

How to remove all files from a directory?

From Dev

How to download all files from hidden directory

From Dev

List all .mp3 files recursive from directory

From Dev

how to select list of directory and read files from those directory in R

From Dev

How to list all source files in a certain directory using Make

From Dev

How to list all files in a directory with absolute paths

From Dev

how to list all files and directories in given directory with full path but not recursive?

From Dev

How to copy all files from a directory to a remote directory using scp?

From Dev

how to list all files in directory - deployment

From Dev

How to retrieve a list of all files in the Working Directory

From Dev

How to list all zip files in a directory?

From Dev

How to list all newly created files in a specific directory?

From Dev

How to list all files in current directory whose second character is a digit?

From Dev

List all XML files in directory, from newest to oldest

From Dev

How to recursively list all files of desired file type in a specified directory?

From Dev

How to list all files in named directory, file type included?

From Dev

How to get a list of all owners of files in a directory

From Dev

How to change the extension of all files from a directory?

Related Related

  1. 1

    How to list all CSV files in a Windows Directory using C++?

  2. 2

    Python 2.7 How to list files in a directory AND all sub directories?

  3. 3

    Search and List all files from directory/subdirectories into ListBox

  4. 4

    How to load all files of a folder to a list of Resources in Spring?

  5. 5

    Android: How to list all the files in a directory in to an array?

  6. 6

    Cordova list all files from application directory (WWW)

  7. 7

    Cocos2d-x How to list all files from a resource directory

  8. 8

    How to retrieve a list of all files in the Working Directory

  9. 9

    How to list recently deleted files from a directory?

  10. 10

    How to get all the files from a directory in xslt

  11. 11

    How to move all files from current directory to upper directory?

  12. 12

    How to remove all files from a directory?

  13. 13

    How to download all files from hidden directory

  14. 14

    List all .mp3 files recursive from directory

  15. 15

    how to select list of directory and read files from those directory in R

  16. 16

    How to list all source files in a certain directory using Make

  17. 17

    How to list all files in a directory with absolute paths

  18. 18

    how to list all files and directories in given directory with full path but not recursive?

  19. 19

    How to copy all files from a directory to a remote directory using scp?

  20. 20

    how to list all files in directory - deployment

  21. 21

    How to retrieve a list of all files in the Working Directory

  22. 22

    How to list all zip files in a directory?

  23. 23

    How to list all newly created files in a specific directory?

  24. 24

    How to list all files in current directory whose second character is a digit?

  25. 25

    List all XML files in directory, from newest to oldest

  26. 26

    How to recursively list all files of desired file type in a specified directory?

  27. 27

    How to list all files in named directory, file type included?

  28. 28

    How to get a list of all owners of files in a directory

  29. 29

    How to change the extension of all files from a directory?

HotTag

Archive