My Java application needs to be able to find a myconfig/
directory which will be bundled inside the same JAR:
myjar.jar/
com/
me/
You can use the PathMatchingResourcePatternResolver
provided by Spring.
public class SpringResourceLoader {
public static void main(String[] args) throws IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// Ant-style path matching
Resource[] resources = resolver.getResources("/myconfig/**");
for (Resource resource : resources) {
InputStream is = resource.getInputStream();
...
}
}
}
I didn't do anything fancy with the returned Resource
but you get the picture.
Add this to your maven dependency (if using maven):
org.springframework
spring-core
3.1.2.RELEASE