* @param resourceName 要查找的资源名, 就是以"/"分隔的标识符字符串
* @return resource的URL数组, 如果没找到, 则返回空数组. 数组中保证不包含重复的URL.
*/
public static URL[] getResources(String resourceName) {
ClassLoader classLoader = null;
Set urlSet = new ArrayHashSet();
boolean found = false;
// 首先试着从当前线程的ClassLoader中查找.
found = getResources(urlSet, resourceName, getClassLoader(), false);
// 如果没找到, 试着从装入自己的ClassLoader中查找.
if (!found) {
getResources(urlSet, resourceName, ContextClassLoader.class.getClassLoader(), false);
}
// 最后的尝试: 在系统ClassLoader中查找(JDK1.2以上),
// 或者在JDK的内部ClassLoader中查找(JDK1.2以下).
if (!found) {
getResources(urlSet, resourceName, null, true);
}
if (found) {
return (URL[]) urlSet.toArray(new URL[urlSet.size()]);
}
return new URL[0];
}