5

I have some Maven dependency with plenty of resources inside. I want to iterate over these resources in my code. How can I do it?

I see several options.

1) I may read Jat with some code similair to the one shown here: Read contents of jar file given specific path

The problem is that I have to specify exact path to mu jar file which is an issue because:

  1. it is located in classpath. I dont know exact path.
  2. it may change from build to build as it contains artefact version.

2) I may read resources using Resources.getResource or some other typical "read-from-classpath" approach (like this one for example: Reading a resource file from within jar). But I have never seen any code that may read resources one by one from some folder. Only code which reads one resource with predefined name.

Is there any ideal approach for my task?

Community
  • 1
  • 1
MiamiBeach
  • 3,261
  • 6
  • 28
  • 54
  • possible duplicate of [How do I list the files inside a JAR file?](http://stackoverflow.com/questions/1429172/how-do-i-list-the-files-inside-a-jar-file) – RealSkeptic Aug 04 '15 at 17:34

0 Answers0