From a50fda1a5eb893ad4dc73a2c58fe57d072f007b4 Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Sun, 15 Aug 2010 03:31:16 +0200 Subject: [PATCH] add ClassLoader.getResources calls --- classpath/java/lang/ClassLoader.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/classpath/java/lang/ClassLoader.java b/classpath/java/lang/ClassLoader.java index 9cb5b0e664..3cc052ac48 100644 --- a/classpath/java/lang/ClassLoader.java +++ b/classpath/java/lang/ClassLoader.java @@ -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 getSystemResources(String name) throws IOException { + return getSystemClassLoader().getResources(name); + } + + public Enumeration getResources(String name) + throws IOException { + Collection resources = collectResources(name); + return Collections.enumeration(resources); + } + + private Collection collectResources(String name) { + Collection urls = parent != null ? parent.collectResources(name) : new ArrayList(5); + URL url = findResource(name); + if (url != null) { + urls.add(url); + } + return urls; + } + }