jetbrick-commons/src/main/java/jetbrick/beans/ClassLoaderUtils.java
public static URL getResource(String name, ClassLoader classLoader) {
        Validate.notNull(name, "resourceName must be not null");

        if (name.startsWith("/")) {
            name = name.substring(1);
        }
        if (classLoader != null) {
            URL url = classLoader.getResource(name);
            if (url != null) {
                return url;
            }
        }
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader != null && loader != classLoader) {
            URL url = loader.getResource(name);
            if (url != null) {
                return url;
            }
        }

        return ClassLoader.getSystemResource(name);
    }
public static URL getResource(String name, ClassLoader classLoader) {
        Validate.notNull(name, "resourceName must be not null");

        if (name.startsWith("/")) {
            name = name.substring(1);
        }
        if (classLoader != null) {
            URL url = classLoader.getResource(name);
            if (url != null) {
                return url;
            }
        }
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader != null && loader != classLoader) {
            URL url = loader.getResource(name);
            if (url != null) {
                return url;
            }
        }

        return ClassLoader.getSystemResource(name);
    }
public static URL getResource ( String name , ClassLoader classLoader ) { Validate . notNull ( name , "resourceName must be not null" ) ; if ( name . startsWith ( "/" ) ) { name = name . substring ( 1 ) ; } if ( classLoader != null ) { URL url = classLoader . getResource ( name ) ; if ( url != null ) { return url ; } } ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader != null && loader != classLoader ) { URL url = loader . getResource ( name ) ; if ( url != null ) { return url ; } } return ClassLoader . getSystemResource ( name ) ; }
Finds the resource with the given name.
@param name - The resource name
@return A URL object for reading the resource, or null if the resource could not be found
Finds the resource with the given name .