private static URL getResource ( String name , ClassLoader [ ] classLoaders ) { // Java standard class loader require resource name to be an absolute path without leading path separator // at this point <name> argument is guaranteed to not start with leading path separator for ( ClassLoader classLoader : classLoaders ) { URL url = classLoader . getResource ( name ) ; if ( url == null ) { // it seems there are class loaders that require leading path separator // not confirmed rumor but found in similar libraries url = classLoader . getResource ( ' ' + name ) ; } if ( url != null ) { return url ; } } return null ; }
Get named resource URL from a list of class loaders . Traverses class loaders in given order searching for requested resource . Return first resource found or null if none found .