Package org.ldaptive.io
Class ResourceUtils
- java.lang.Object
-
- org.ldaptive.io.ResourceUtils
-
public final class ResourceUtils extends Object
Provides utility methods for resources.
-
-
Field Summary
Fields Modifier and Type Field Description private static ResourceLoader[]customResourceLoadersCustom resource loaders.private static ResourceLoader[]DEFAULT_RESOURCE_LOADERSDefault resource loaders.
-
Constructor Summary
Constructors Modifier Constructor Description privateResourceUtils()Default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InputStreamgetResource(String path)static InputStreamgetResource(String path, ResourceLoader... loaders)Attempts to find aResourceLoaderthat supports the supplied path.static booleanisResource(String path)static booleanisResource(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 voidsetCustomResourceLoaders(ResourceLoader... loaders)Sets the custom resource loaders.
-
-
-
Field Detail
-
DEFAULT_RESOURCE_LOADERS
private static final ResourceLoader[] DEFAULT_RESOURCE_LOADERS
Default resource loaders.
-
customResourceLoaders
private static ResourceLoader[] customResourceLoaders
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(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(String path)
- Parameters:
path- to inspect- Returns:
- whether the supplied string represents a resource
-
getResource
public static InputStream getResource(String path, ResourceLoader... loaders) throws IOException
Attempts 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:
IOException- if the resource cannot be readIllegalArgumentException- if path is not supported
-
getResource
public static InputStream getResource(String path) throws IOException
- 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
public static byte[] readResource(String path, ResourceLoader... loaders) throws IOException
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
public static byte[] readResource(String path) throws IOException
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
-
-