Returns the given source as an {@link URL}

@param contextClass
@param resourceName
@return
345177
public static URL asURL(Class<?> contextClass, String resourceName) {
		return Resources.getResource(contextClass, resourceName);
	}
891554
public static URL getResource(String resource, Class<?> context, boolean checkParent)
    {
        URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (url != null)
            return url;

        if (context != null)
        {
            ClassLoader loader = context.getClassLoader();
            while (loader != null)
            {
                url = loader.getResource(resource);
                if (url != null)
                    return url;
                loader = checkParent ? loader.getParent() : null;
            }
        }

        return ClassLoader.getSystemResource(resource);
    }
472061
public InputStream getResourceAsStream(String resourceName, BeanContextChild child) throws IllegalArgumentException
	{
		if (resourceName == null || child == null)
		{
			throw new NullPointerException();
		}
		if (!contains(child))
		{
			throw new IllegalArgumentException(Messages.getString("beans.6D"));
		}

		return ClassLoader.getSystemResourceAsStream(resourceName);
	}
604914
@Override
	@Pure
	public URL findResource(final String name) {
		/*
		 * The same restriction to finding classes applies to resources
		 */
		final URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
				@Override
				public URL run() {
					return DynamicURLClassLoader.this.ucp.findResource(name, true);
				}
			}, this.acc);

		return url != null ? this.ucp.checkURL(url) : null;
	}
478725
public static String getClassName(String resourceName) {
    if (!resourceName.endsWith(".class")) {
      throw new IllegalArgumentException("resourceName does not refer to a class");
    }
    int len = resourceName.length();
    return resourceName.substring(0, len - 6).replace('/', '.');
  }
331035
public static Enumeration<URL> getResources(String resourcePath, Object source) {

		// Try the current classloader
		Enumeration<URL> urls = null;

		ClassLoader cl = source.getClass().getClassLoader();
		try {
			if (null != cl) {
				urls = cl.getResources(resourcePath);
			}

			// If current classloader failed, try with the Threads context
			// classloader. If that fails ott, the resource is either not on the
			// classpath or inaccessible from the current context.

			if (null == urls) {
				urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
			}

			// Last chance, hack in the classloader
			if (null == urls) {
				ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
				try {
					Thread.currentThread().setContextClassLoader(source.getClass().getClassLoader());
					if (Thread.currentThread().getContextClassLoader() != null) {

						urls = Thread.currentThread().getContextClassLoader().getResources(resourcePath);
					}
				} finally {
					Thread.currentThread().setContextClassLoader(threadClassLoader);
				}
			}
		} catch (IOException e) {
			LOGGER.warn("Unable to load " + resourcePath, e);
		}

		return urls;
	}
564893
public static URL getResource(String ref) {

		URL url = null;
		
		for (int i=0;i<locations.size();i++) {
			ResourceLocation location = (ResourceLocation) locations.get(i);
			url = location.getResource(ref);
			if (url != null) {
				break;
			}
		}
		
		if (url == null)
		{
			throw new RuntimeException("Resource not found: "+ref);
		}
			
		return url;
	}
603580
public URLConnection getResourceConnection(String resourceName) throws ResourceException {
        // Get the URLConnection
        URLConnection groovyScriptConn = null;

        ResourceException se = null;
        for (URL root : roots) {
            URL scriptURL = null;
            try {
                scriptURL = new URL(root, resourceName);
                groovyScriptConn = openConnection(scriptURL);

                break; // Now this is a bit unusual
            } catch (MalformedURLException e) {
                String message = "Malformed URL: " + root + ", " + resourceName;
                if (se == null) {
                    se = new ResourceException(message);
                } else {
                    se = new ResourceException(message, se);
                }
            } catch (IOException e1) {
                String message = "Cannot open URL: " + root + resourceName;
                groovyScriptConn = null;
                if (se == null) {
                    se = new ResourceException(message);
                } else {
                    se = new ResourceException(message, se);
                }
            }
        }

        if (se == null) se = new ResourceException("No resource for " + resourceName + " was found");

        // If we didn't find anything, report on all the exceptions that occurred.
        if (groovyScriptConn == null) throw se;
        return groovyScriptConn;
    }
1293696
public URL getResourceFrom(String name, AbstractClassLoader first) {
		if (name.length() == 0) return null;
		if (name.charAt(0) == '/') name = name.substring(1);
		URL url = null;
    	// try with the first one
    	if (first != null)
   			url = first.getResourceURL(name);
    	// then, try on other libraries
    	if (url == null) {
        	for (int i = 0; i < libs.size(); i++) {
        		AbstractClassLoader cl = libs.get(i);
        		if (cl == first) continue;
       			url = cl.getResourceURL(name);
        		if (url != null) break;
        	}
        }
        if (url == null)
        	url = AppClassLoader.class.getClassLoader().getResource(name);
        return url;
	}
901719
@Override
	public InputStream createResourceAsStream(GeneratorContext context) {

		String path = context.getPath();
		return rd.getResourceAsStream(path);
	}
400105
public static URL getResourceURL(String resource) throws IOException {
    URL url = null;
    ClassLoader loader = ResourcesUtils.class.getClassLoader();
    if (loader != null) {
      url = loader.getResource(resource);
    }
    if (url == null) {
      url = ClassLoader.getSystemResource(resource);
    }
    if (url == null) {
      throw new IOException("Could not find resource " + resource);
    }
    return url;
  }
734597
public static Uri getUriFromResource(@NonNull Context context, @AnyRes int resId) throws Resources.NotFoundException {
        /** Return a Resources instance for your application's package. */
        Resources res = context.getResources();
        /**
         * Creates a Uri which parses the given encoded URI string.
         * @param uriString an RFC 2396-compliant, encoded URI
         * @throws NullPointerException if uriString is null
         * @return Uri for this given uri string
         */
        /** return uri */
        return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
                "://" + res.getResourcePackageName(resId)
                + '/' + res.getResourceTypeName(resId)
                + '/' + res.getResourceEntryName(resId));
    }
925636
@Override
  public InputStream getResourceAsStream(String name)
  {
    ResourceEntry entry = _resourceCacheMap.get(name);
    
    if (entry == null || entry.isModified()) {
      URL resource = super.getResource(name);
    
      entry = new ResourceEntry(resource);
    
      _resourceCacheMap.put(name, entry);
    }
    
    return entry.getResourceAsStream();
  }
463928
public static CharSource asCharSource(final Class<?> contextClass, final String resourceName) {
		return asCharSource(contextClass, resourceName, Charsets.UTF_8);
	}
979879
@Override
    public ViewResource createViewResource(FacesContext context, String resourceName) {
        return getWrapped().createViewResource(context, resourceName);
    }
1101997
public static CharSource asCharSource(final Class<?> contextClass, final String resourceName, final Charset charset) {
		return new CharSource() {
			@Override public Reader openStream() throws IOException {
				return asReader(checkNotNull(contextClass).getResourceAsStream(checkNotEmpty(resourceName)), checkNotNull(charset));
			}
		};
	}
261267
public void setSourceUrl(GlobusURL source)
        throws UrlCopyException {
        if (source == null) {
            throw new IllegalArgumentException("Source url cannot be null");
        }
        checkUrl(source);
        srcUrl = source;
    }