Package org.ldaptive.io
Class ResourceUtils
- java.lang.Object
-
- org.ldaptive.io.ResourceUtils
-
public final class ResourceUtils extends java.lang.ObjectProvides utility methods for resources.- Author:
- Middleware Services
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.InputStreamgetResource(java.lang.String path)InvokesgetResource(String, ResourceLoader...)withDEFAULT_RESOURCE_LOADERS.static java.io.InputStreamgetResource(java.lang.String path, ResourceLoader... loaders)Attempts to find aResourceLoaderthat supports the supplied path.static booleanisResource(java.lang.String path)InvokesisResource(String, ResourceLoader...)withDEFAULT_RESOURCE_LOADERS.static booleanisResource(java.lang.String path, ResourceLoader... loaders)Returns whether the supplied path is supported by aResourceLoader.static byte[]readResource(java.lang.String path)Reads the data from the supplied resource path.static byte[]readResource(java.lang.String path, ResourceLoader... loaders)Reads the data from the supplied resource path using the supplied loaders.static voidsetCustomResourceLoaders(ResourceLoader... loaders)Sets the custom resource loaders.
-
-
-
Method Detail
-
setCustomResourceLoaders
public static void setCustomResourceLoaders(ResourceLoader... loaders)
Sets the custom resource loaders.- Parameters:
loaders- custom resource loaders
-
isResource
public static boolean isResource(java.lang.String path, ResourceLoader... loaders)Returns whether the supplied path is supported by aResourceLoader.- Parameters:
path- to inspectloaders- to invokeResourceLoader.supports(String)on- Returns:
- whether the supplied string represents a resource
-
isResource
public static boolean isResource(java.lang.String path)
InvokesisResource(String, ResourceLoader...)withDEFAULT_RESOURCE_LOADERS.- Parameters:
path- to inspect- Returns:
- whether the supplied string represents a resource
-
getResource
public static java.io.InputStream getResource(java.lang.String path, ResourceLoader... loaders) throws java.io.IOExceptionAttempts to find aResourceLoaderthat supports the supplied path. If found, that resource loader is used to load the input stream.- Parameters:
path- that designates a resourceloaders- to invokeResourceLoader.load(String)on- Returns:
- input stream to read the resource
- Throws:
java.io.IOException- if the resource cannot be readjava.lang.IllegalArgumentException- if path is not supported
-
getResource
public static java.io.InputStream getResource(java.lang.String path) throws java.io.IOExceptionInvokesgetResource(String, ResourceLoader...)withDEFAULT_RESOURCE_LOADERS.- Parameters:
path- that designates a resource- Returns:
- input stream to read the resource
- Throws:
java.io.IOException- if the resource cannot be readjava.lang.IllegalArgumentException- if path is not supported
-
readResource
public static byte[] readResource(java.lang.String path, ResourceLoader... loaders) throws java.io.IOExceptionReads the data from the supplied resource path using the supplied loaders. SeegetResource(String, ResourceLoader...)andLdapUtils.readInputStream(InputStream).- Parameters:
path- that designates a resourceloaders- to invokegetResource(String, ResourceLoader...)with- Returns:
- bytes read from the resource
- Throws:
java.io.IOException- if the resource cannot be read
-
readResource
public static byte[] readResource(java.lang.String path) throws java.io.IOExceptionReads the data from the supplied resource path. SeegetResource(String)andLdapUtils.readInputStream(InputStream).- Parameters:
path- that designates a resource- Returns:
- bytes read from the resource
- Throws:
java.io.IOException- if the resource cannot be read
-
-