Package org.cryptacular.io
Class ClassPathResource
java.lang.Object
org.cryptacular.io.ClassPathResource
- All Implemented Interfaces:
Resource
Resource that produces a
InputStream
from a classpath resource.- Author:
- Middleware Services
-
Constructor Summary
ConstructorsConstructorDescriptionClassPathResource
(String path) Creates a new resource that reads from the given classpath location.ClassPathResource
(String path, ClassLoader loader) Creates a new resource that reads from the given classpath location. -
Method Summary
Modifier and TypeMethodDescriptionGets an input stream around the resource.
-
Constructor Details
-
ClassPathResource
Creates a new resource that reads from the given classpath location.Thread.currentThread().getContextClassLoader()
is used to obtain the class loader used to obtain an input stream on the given classpath.- Parameters:
path
- Classpath location.
-
ClassPathResource
Creates a new resource that reads from the given classpath location.- Parameters:
path
- Classpath location.loader
- Class loader used to obtain an input stream on the given classpath location.
-
-
Method Details
-
getInputStream
Description copied from interface:Resource
Gets an input stream around the resource. Callers of this method are responsible for resource cleanup; it should be sufficient to simply callInputStream.close()
unless otherwise noted.Implementers should produce a new instance on every call to this method to provide for thread-safe usage patterns on a shared resource.
- Specified by:
getInputStream
in interfaceResource
- Returns:
- Input stream around underlying resource, e.g. file, remote resource (URI), etc.
-