I have a collection of resources on the classpath something along the lines:
com/example/foo r1.txt r2.txt r3.txt bar/ b1.txt b2.txt baz/ x.txt y.txt I know that this package is on the class-path sitting in WEB-INF lib, what I want to able to traverse the class-path starting at com.example.foo looking for all the .txt files. Call a function with siganutre similar to the following.
List files = findFiles("com/example/foo","*.txt");
I am using spring 3.1 so I am happy to use any methods that are part of spring.
UPDATE: Solution using Spring based @jschoen suggestion below:
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] resources = resolver.getResources("classpath:com/example/foo/**/*.txt"); The spring matches using ant style patters thus the need for the double **