Java Utililty Methods Resource Get

List of utility methods to do Resource Get

  1. HOME
  2. Java
  3. R
  4. Resource Get

Description

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

Method

URL getResource(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;
URL getResource(Class baseclass, String name)
E.g.
return baseclass.getResource("resources/" + name);
String getResource(Class c, String name)
get Resource
try {
 return c.getResource(name).toURI().toString();
} catch (URISyntaxException e) {
 throw new RuntimeException(e);
URL getResource(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) {
...
URL getResource(Class controllerClass)
Find the .fxml resource associated with a given controller class by location and naming conventions.
return getResource(controllerClass, getResourceName(controllerClass));
URL getResource(Class testClass, String resource)
get Resource
return testClass.getResource(getResourcePath(testClass, resource));
URL getResource(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;
URL getResource(final Class aClass, final String aName)
Returns the resource with the given name from the "datafiles"-directory.
return getResource(aClass, "datafiles", aName);
URL getResource(final String name)
Get resource in privileged mode.
return Thread.currentThread().getContextClassLoader().getResource(name);
URL getResource(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;


AltStyle によって変換されたページ (->オリジナル) /