public static URL locateOnClasspath ( String resourceName ) { URL url = null ; // attempt to load from the context classpath ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader != null ) { url = loader . getResource ( resourceName ) ; if ( url != null ) { log . debug ( "Located '{}' in the context classpath" , resourceName ) ; } } // attempt to load from the system classpath if ( url == null ) { url = ClassLoader . getSystemResource ( resourceName ) ; if ( url != null ) { log . debug ( "Located '{}' in the system classpath" , resourceName ) ; } } return url ; }
Tries to find a resource with the given name in the classpath .