This implementation returns a URL for the underlying class path resource,
if available.
@see java.lang.ClassLoader#getResource(String)
@see java.lang.Class#getResource(String)
513168
@Override
	public URL getURL() throws IOException {
		URL url = resolveURL();
		if (url == null) {
			throw new FileNotFoundException(getDescription() + " cannot be resolved to URL because it does not exist");
		}
		return url;
	}
715313
public static URL getSourceUrl(SourceUnit source) {
        URL url = null;
        final String filename = source.getName();
        if(filename==null) {
            return null;
        }

        Resource resource = new FileSystemResource(filename);
        if (resource.exists()) {
            try {
                url = resource.getURL();
            } catch (IOException e) {
                // ignore
            }
        }
        return url;
    }
6710
public URL getResourceURL(String filepath, URL urlCodeBase, String version, ClassLoader classLoader) throws RuntimeException
    {
        if (filepath == null)
            return null;
        if (File.separatorChar != '/')
            filepath = filepath.replace(File.separatorChar, '/'); // Just in case I get a window's path

        boolean isResource = true;
        if (urlCodeBase != null)
        	if ("file".equalsIgnoreCase(urlCodeBase.getProtocol()))
        		isResource = false;
        URL url = null;
        try {
        	if (isResource)
        		if (classLoader != null)
        		{
        			url = classLoader.getResource(filepath);
        			if (url == null)
        			    if (filepath.startsWith("/"))
        			        url = classLoader.getResource(filepath.substring(1));    // Classpaths shouldn't start with root
        		}
        } catch (Exception e) {
            // Keep trying
        }

        if (url == null)
        {
        	if (isResource)
        		if (this.getClassFinder(null) != null)
        			url = this.getClassFinder(null).findResourceURL(filepath, version);	// Try to find this class in the obr repos
        }

        if (url == null)
        {
            try
            {
                if (urlCodeBase != null)
                    url = new URL(urlCodeBase, filepath);
            } catch(MalformedURLException ex) {
                // Keep trying
            } catch (Exception e) {
                // Keep trying
            }
        }
        return url;
    }
609581
@Override
	public Enumeration<URL> getResources(String name) throws IOException {
		return bundleClassLoader.getResources(name);
	}
1312793
public URL getResource(String path) throws MalformedURLException {

		URL url = null;
		File file = new File(baseDir + path);
		if (file.exists()) {
			url = file.toURI().toURL();
		}
		return url;
	}
333964
@Override
    protected URL getURL(String name) {
        return Thread.currentThread().getContextClassLoader().getResource(name);
    }
1239604
public Optional<URL> getResource(String path) {
        boolean isDirectory = isDirectory(path);

        if (!isDirectory) {
            URL url = classLoader.getResource(prefixPath(path));
            return Optional.ofNullable(url);
        }
        return Optional.empty();
    }
647625
@Override
    public URL getResource(final String path) {
        final ResourceList resourceList = scanResult.getResourcesWithPath(path);
        if (resourceList == null || resourceList.isEmpty()) {
            return super.getResource(path);
        } else {
            return resourceList.get(0).getURL();
        }
    }
622435
@Override
    public URL findResource(final String name)
    {
        return AccessController.doPrivileged(new PrivilegedAction<URL>()
        {
            @Override
            public URL run()
            {
                return URIClassLoader.this.finder.findResource(name);
            }
        }, this.acc);
    }
590991
@Nullable
  public URL getResource (final String name)
  {
    URL ret = null;

    if (m_aBestCandidate != null)
    {
      ret = m_aBestCandidate.getResource (name);
      if (ret != null)
        return ret;
      m_aBestCandidate = null;
    }

    IClassLoadHelper aLoadHelper = null;

    final Iterator <IClassLoadHelper> iter = m_aLoadHelpers.iterator ();
    while (iter.hasNext ())
    {
      aLoadHelper = iter.next ();
      ret = aLoadHelper.getResource (name);
      if (ret != null)
        break;
    }

    m_aBestCandidate = aLoadHelper;
    return ret;
  }
179834
public static InputStream getResourceStream(final String path) {
		final ClassLoader loader = Resources.class.getClassLoader();
		return loader.getResourceAsStream(path);
	}
1179417
protected final Optional<URL> defaultGetResource(String name) {
        return Optional.ofNullable(getClassLoader().getResource(name));
    }
364027
private static ClassPath getAPIClassPath() throws IOException {
    ClassLoader classLoader = Flow.class.getClassLoader();
    String resourceName = Flow.class.getName().replace('.', '/') + ".class";
    URL url = classLoader.getResource(resourceName);
    if (url == null) {
      throw new IOException("Resource not found for " + resourceName);
    }

    try {
      URI classPathURI = getClassPathURL(resourceName, url).toURI();
      return ClassPath.from(classPathURI, classLoader);
    } catch (URISyntaxException e) {
      throw new IOException(e);
    }
  }
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;
  }
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;
	}
776282
public static HttpFileBuilder ofResource(ClassLoader classLoader, String path) {
        requireNonNull(classLoader, "classLoader");
        requireNonNull(path, "path");

        // Strip the leading slash.
        if (path.startsWith("/")) {
            path = path.substring(1);
        }

        // Retrieve the resource URL.
        final URL url = classLoader.getResource(path);
        if (url == null || url.getPath().endsWith("/")) {
            // Non-existent resource.
            return new NonExistentHttpFileBuilder();
        }

        // Convert to a real file if possible.
        if ("file".equals(url.getProtocol())) {
            File f;
            try {
                f = new File(url.toURI());
            } catch (URISyntaxException ignored) {
                f = new File(url.getPath());
            }

            return of(f);
        }

        return new ClassPathHttpFileBuilder(url);
    }
700054
@Override
  public URL getResource(String name) {

    URL result = null;

    if (bestCandidate != null) {
      result = bestCandidate.getResource(name);
      if (result == null) {
        bestCandidate = null;
      }
    }

    ClassLoadHelper loadHelper = null;

    Iterator<ClassLoadHelper> iter = loadHelpers.iterator();
    while (iter.hasNext()) {
      loadHelper = iter.next();

      result = loadHelper.getResource(name);
      if (result != null) {
        break;
      }
    }

    bestCandidate = loadHelper;
    return result;
  }