add ClassLoader.getResources calls

This commit is contained in:
Zsombor Gegesy 2010-08-15 03:31:16 +02:00 committed by Joel Dice
parent 03b66375f4
commit a50fda1a5e

View File

@ -13,6 +13,10 @@ package java.lang;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
public abstract class ClassLoader {
private final ClassLoader parent;
@ -123,4 +127,24 @@ public abstract class ClassLoader {
public static InputStream getSystemResourceAsStream(String path) {
return getSystemClassLoader().getResourceAsStream(path);
}
public static Enumeration<URL> getSystemResources(String name) throws IOException {
return getSystemClassLoader().getResources(name);
}
public Enumeration<URL> getResources(String name)
throws IOException {
Collection<URL> resources = collectResources(name);
return Collections.enumeration(resources);
}
private Collection<URL> collectResources(String name) {
Collection<URL> urls = parent != null ? parent.collectResources(name) : new ArrayList<URL>(5);
URL url = findResource(name);
if (url != null) {
urls.add(url);
}
return urls;
}
}