Java Utililty Methods Resource Get

List of utility methods to do Resource Get

Description

The list of methods to do Resource Get are organized into topic(s).

Method

URIgetResource(final String resource)
get Resource
return getClassLoader().getResource(resource).toURI();
URLgetResource(final String resourceName, final Class caller)
get Resource
final String resource;
if (resourceName.startsWith("/")) {
    resource = resourceName.substring(1);
} else {
    final Package callerPackage = caller.getPackage();
    if (callerPackage != null) {
        resource = callerPackage.getName().replace('.', '/') + '/' + resourceName;
    } else {
...
URLgetResource(String filename)
get Resource
Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
return contextClassLoader.getResource(filename);
URLgetResource(String filename)
Returns a url to a resource.
URL url = ClassLoader.getSystemResource(filename);
if (url == null) {
    url = Main.class.getResource(filename);
    if (url == null) {
        try {
            url = new File(filename).toURL();
        } catch (MalformedURLException e) {
            return null;
...
URLgetResource(String folder, String name)
Get URL of a resource from a given folder.
return getResource(folder + "/" + name);
InputStreamgetResource(String inResource)
trying to fetch data from the following resources CLASSPATH, FILE, URL
return getResource(inResource, true);
StringgetResource(String key, String bundleName, Locale locale)
Returns the localized string with the given key from the given bundle.
try {
    ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
    return bundle.getString(key);
} catch (MissingResourceException e) {
    return "??? " + key + " ???";
URLgetResource(String name)
get Resource
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = null;
if ((name != null) && (name.indexOf(":/") > -1)) {
    try {
        url = new URL(name);
    } catch (Exception e) {
if (url == null) {
    try {
        url = classLoader.getResource(name);
    } catch (Exception e) {
if (url == null) {
    try {
        url = classLoader.getResource('/' + name);
    } catch (Exception e) {
if (url == null) {
    try {
        url = classLoader.getResource("META-INF/" + name);
    } catch (Exception e) {
return url;
URLgetResource(String name)
get Resource
return Thread.currentThread().getContextClassLoader().getResource(name);
URLgetResource(String name)
get Resource
if (!name.startsWith("bio/gcat/"))
    name = "bio/gcat" + (name.startsWith("/") ? EMPTY : "/") + name;
return localClassLoader.getResource(name);