Java Utililty Methods Resource Find

List of utility methods to do Resource Find

Description

The list of methods to do Resource Find are organized into topic(s).

Method

URLfindResource(Class clazz)
find Resource
if (clazz.isArray()) {
    clazz = clazz.getComponentType();
if (clazz.isPrimitive()) {
    return null;
ClassLoader loader = (clazz.getClassLoader() != null ? clazz.getClassLoader()
        : ClassLoader.getSystemClassLoader());
...
URLfindResource(Class clazz)
find Resource
if (clazz.isArray())
    clazz = clazz.getComponentType();
if (clazz.isPrimitive())
    return null;
URL url = getClassLoader(clazz).getResource(toResourceName(clazz));
String path = url.toString();
if (path.indexOf(' ') != -1) {
    try {
...
URLfindResource(String name)
XXX Abstraction around how we find resources, do something smarter in the future.
return ClassLoader.getSystemResource(name);
StringfindResource(String resource, ClassLoader classLoader)
find Resource
String urls = "";
URL url = classLoader.getResource(resource);
if (url == null) {
    urls = "\t" + resource + " not found\n";
} else {
    urls = "\t" + url.toString() + "\n";
Enumeration<?> en = classLoader.getResources(resource);
...
URLfindResourceBase(String baseResource, ClassLoader loader)
Find the classpath URL for a specific classpath resource.
URL url = loader.getResource(baseResource);
return findResourceBase(url, baseResource);
URL[]findResourceBases(String baseResource, ClassLoader loader)
Find the classpath URLs for a specific classpath resource.
ArrayList<URL> list = new ArrayList<URL>();
try {
    Enumeration<URL> urls = loader.getResources(baseResource);
    while (urls.hasMoreElements()) {
        URL url = urls.nextElement();
        list.add(findResourceBase(url, baseResource));
} catch (IOException e) {
...
ListfindResources(String name)
find Resources
try {
    Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(name);
    List<URL> ret = new ArrayList<URL>();
    while (resources.hasMoreElements()) {
        ret.add(resources.nextElement());
    return ret;
} catch (IOException e) {
...