Did not try this on all VMs, but on a recent Oracle VM there is a shorter way:
Enumeration resources = Thread.currentThread().getContextClassLoader().getResources("package/name/with/slashes/instead/dots");
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
System.out.println(url);
System.out.println(new Scanner((InputStream) url.getContent()).useDelimiter("\\A").next());
}
This will print out the names of the resources in the package, so you can use getResource(...) on them. The call url.getContent() will return an instance of sun.net.www.content.text.PlainTextInputStream which is a VM specific class.