public class ResourceLoader
extends java.lang.Object
Constructor and Description |
---|
ResourceLoader() |
Modifier and Type | Method and Description |
---|---|
static java.net.URL |
getClasspathResourceAsURL(java.lang.String resourceName,
java.lang.String resource,
java.lang.ClassLoader classLoader)
Returns an URL from an application resource in the classpath.
|
static java.net.URL |
resolveClassPathOrURLResource(java.lang.String resourceName,
java.lang.String urlOrClasspathResource,
java.lang.ClassLoader classLoader)
Resolve a resource into a URL using the URL string or classpath-relative filename and
using a name for any exceptions thrown.
|
public static java.net.URL resolveClassPathOrURLResource(java.lang.String resourceName, java.lang.String urlOrClasspathResource, java.lang.ClassLoader classLoader) throws java.io.FileNotFoundException
resourceName
- is the name for use in exceptionsurlOrClasspathResource
- is a URL string or classpath-relative filenameclassLoader
- class loaderjava.io.FileNotFoundException
- resource not foundpublic static java.net.URL getClasspathResourceAsURL(java.lang.String resourceName, java.lang.String resource, java.lang.ClassLoader classLoader) throws java.io.FileNotFoundException
The method first removes the '/' character from the resource name if the first character is '/'.
The lookup order is as follows:
If a thread context class loader exists, use Thread.currentThread().getResourceAsStream to obtain an InputStream.
If no input stream was returned, use the Configuration.class.getResourceAsStream. to obtain an InputStream.
If no input stream was returned, use the Configuration.class.getClassLoader().getResourceAsStream. to obtain an InputStream.
If no input stream was returned, throw an Exception.
resourceName
- is the name for use in exceptionsresource
- is the classpath-relative filename to resolve into a URLclassLoader
- class loaderjava.io.FileNotFoundException
- resource not found