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

URLgetResource(Class _class, String resource)
Find the requested resource (file) like Class.getResource(), but it works for both applets and applications.
URL url = _class.getResource(resource);
if (url == null) {
return url;
URLgetResource(Class baseclass, String name)
E.g.
return baseclass.getResource("resources/" + name);
StringgetResource(Class c, String name)
get Resource
try {
    return c.getResource(name).toURI().toString();
} catch (URISyntaxException e) {
    throw new RuntimeException(e);
URLgetResource(Class clazz, String resource)
get Resource
if (resource == null || resource.trim().length() == 0) {
    throw new IllegalArgumentException("resource is null!");
URL url = null;
if (clazz != null) {
    url = clazz.getResource(resource);
    if (url == null) {
        if (clazz.getClassLoader() != null) {
...
URLgetResource(Class controllerClass)
Find the .fxml resource associated with a given controller class by location and naming conventions.
return getResource(controllerClass, getResourceName(controllerClass));
URLgetResource(Class testClass, String resource)
get Resource
return testClass.getResource(getResourcePath(testClass, resource));
URLgetResource(final Class clazz, final String res)
get Resource
final URL url = clazz.getResource(res);
if (url == null) {
    throw new RuntimeException("Resource '" + res + "' not found!");
} else {
    return url;
URLgetResource(final Class aClass, final String aName)
Returns the resource with the given name from the "datafiles"-directory.
return getResource(aClass, "datafiles", aName);
URLgetResource(final String name)
Get resource in privileged mode.
return Thread.currentThread().getContextClassLoader().getResource(name);
URLgetResource(final String res)
get Resource
final URL edictGz = Thread.currentThread().getContextClassLoader().getResource(res);
if (edictGz == null) {
    throw new AssertionError("The " + res + " resource is missing");
return edictGz;