You can achieve this using the Spring Framework. Even if you are not developing a Spring application, you can still use their utility methods. You want to use PathMatchingResourcePatternResolver
:
public Resource[] getResources(String package)
{
PathMatchingResourcePatternResolver pmrpr = new PathMatchingResourcePatternResolver();
// turns com.myapp.mypackage into /com/myapp/mypackage/*
return pmrpr.getResources("/" + package.replace(".", "/") + "/*");
}
For reference, see:
If you are using Maven, use this dependency:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>