Java Resource Get getResource(String name)

Here you can find the source of getResource(String name)

Description

get Resource

License

Apache License

Parameter

Parameter Description
name Resource Name

Return

Resource URL

Declaration

public static URL getResource(String name) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.URL;

public class Main {
    /**//from   w w w  . j  a  v  a  2s  .  com
     * @param name Resource Name
     * @return Resource URL
     */
    public static URL getResource(String name) {
        ClassLoader cl = getClassLoader();

        if (cl == null) {
            return null;
        }

        return cl.getResource(name);
    }

    private static ClassLoader getClassLoader() {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();

        if (cl == null) {
            return ClassLoader.getSystemClassLoader();
        }

        return cl;
    }
}

Related

  1. getResource(String name)
  2. getResource(String name)
  3. getResource(String name)
  4. getResource(String name)
  5. getResource(String name)
  6. getResource(String name)
  7. getResource(String name, Class neighbor)
  8. getResource(String name, Class caller)
  9. getResource(String res)