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;
  }
private static URL getResource ( String name , ClassLoader [ ] classLoaders ) { for ( ClassLoader classLoader : classLoaders ) { URL url = classLoader . getResource ( name ) ; if ( url == null ) { 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.

@param name resource name with syntax as requested by Java ClassLoader,
@param classLoaders target class loaders.
@return found resource URL or null.