Package org.ldaptive.io
Class ResourceUtils
java.lang.Object
org.ldaptive.io.ResourceUtils
Provides utility methods for resources.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ResourceLoader[]
Custom resource loaders.private static final ResourceLoader[]
Default resource loaders. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStream
getResource
(String path) static InputStream
getResource
(String path, ResourceLoader... loaders) Attempts to find aResourceLoader
that supports the supplied path.static boolean
isResource
(String path) static boolean
isResource
(String path, ResourceLoader... loaders) Returns whether the supplied path is supported by aResourceLoader
.static byte[]
readResource
(String path) Reads the data from the supplied resource path.static byte[]
readResource
(String path, ResourceLoader... loaders) Reads the data from the supplied resource path using the supplied loaders.static void
setCustomResourceLoaders
(ResourceLoader... loaders) Sets the custom resource loaders.
-
Field Details
-
DEFAULT_RESOURCE_LOADERS
Default resource loaders. -
customResourceLoaders
Custom resource loaders.
-
-
Constructor Details
-
ResourceUtils
private ResourceUtils()Default constructor.
-
-
Method Details
-
setCustomResourceLoaders
Sets the custom resource loaders.- Parameters:
loaders
- custom resource loaders
-
isResource
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
- Parameters:
path
- to inspect- Returns:
- whether the supplied string represents a resource
-
getResource
Attempts to find aResourceLoader
that 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:
IOException
- if the resource cannot be readIllegalArgumentException
- if path is not supported
-
getResource
- Parameters:
path
- that designates a resource- Returns:
- input stream to read the resource
- Throws:
IOException
- if the resource cannot be readIllegalArgumentException
- if path is not supported
-
readResource
Reads 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:
IOException
- if the resource cannot be read
-
readResource
Reads 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:
IOException
- if the resource cannot be read
-