How can I use ClassLoader.getResources()
to find recursivly resources from my classpath?
E.g.
finding all resources in the META-INF
"directory":
Imagine something like
getClass().getClassLoader().getResources("META-INF")
Unfortunately, this does only retrieve an URL
to exactly this "directory".
all resources named bla.xml
(recursivly)
getClass().getClassLoader().getResources("bla.xml")
But this returns an empty Enumeration
.
And as a bonus question: How does ClassLoader.getResources()
differ from ClassLoader.getResource()
?
The Spring Framework has a class which allows to recursively search through the classpath:
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
resolver.getResources("classpath*:some/package/name/**/*.xml");