public class ResourceLocator extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ResourceLocator.SearchOrderItem |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
find(String resourcePath)
Looks for a resource first file system, then the classpath.
|
InputStream |
find(String resourcePath,
Class referenceClass)
Looks for a resource first file system, then the classpath.
|
InputStream |
find(String resourcePath,
Class referenceClass,
List<ResourceLocator.SearchOrderItem> searchOrder)
Looks for a resource from the classpath, file system or as a remote URL.
|
InputStream |
find(String resourcePath,
List<ResourceLocator.SearchOrderItem> searchOrder)
Looks for a resource from the classpath, file system or as a remote URL.
|
static ResourceLocator |
getInstance()
Returns an instance of ResourceLocator.
|
InputStream |
getStreamFromClasspath(String resourcePath)
Returns the byte stream to a resource from the classpath using the system
class loader to find the resource.
|
InputStream |
getStreamFromClasspath(String resourcePath,
Class referenceClass)
Returns the byte stream to a resource from the classpath using a particular
class's class loader to find the resource.
|
URL |
getUrlFromClasspath(String resourcePath)
Returns the URL to a resource from the classpath using the system class
loader to find the resource.
|
URL |
getUrlFromClasspath(String resourcePath,
Class referenceClass)
Returns the URL to a resource from the classpath using a particular class's
class loader to find the resource.
|
public static ResourceLocator getInstance()
public InputStream find(String resourcePath)
resourcePath - resource to look up. Cannot be null nor an blank string.public InputStream find(String resourcePath, Class referenceClass)
resourcePath - resource to look up. Cannot be null nor an blank string.referenceClass - the classloader for this reference class is used to look up the
resource. The system class loader is used if this parameter is not
provided.public InputStream find(String resourcePath, List<ResourceLocator.SearchOrderItem> searchOrder)
resourcePath - resource to look up. Cannot be null nor an blank string.searchOrder - where to look up the resource. If it is null or empty, the default
search order is used, which is to look in the file system, then
the classpath.public InputStream find(String resourcePath, Class referenceClass, List<ResourceLocator.SearchOrderItem> searchOrder)
resourcePath - resource to look up. Cannot be null nor an blank string.referenceClass - the classloader for this reference class is used to look up the
resource. The system class loader is used if this parameter is not
provided.searchOrder - where to look up the resource. If it is null or empty, the default
search order is used, which is to look in the file system, then
the classpath.public InputStream getStreamFromClasspath(String resourcePath)
resourcePath - resource to look up. Cannot be null nor an blank string.public InputStream getStreamFromClasspath(String resourcePath, Class referenceClass)
resourcePath - resource to look up. Cannot be null nor an blank string.referenceClass - the classloader for this reference class is used to look up the
resource. The system class loader is used if this parameter is not
provided.public URL getUrlFromClasspath(String resourcePath)
resourcePath - resource to look up. Cannot be null nor an blank string.public URL getUrlFromClasspath(String resourcePath, Class referenceClass)
resourcePath - resource to look up. Cannot be null nor an blank string.referenceClass - the classloader for this reference class is used to look up the
resource. The system class loader is used if this parameter is not
provided.Copyright © 2021. All rights reserved.