Class ClassPathResource

java.lang.Object
org.cryptacular.io.ClassPathResource
All Implemented Interfaces:
Resource

public class ClassPathResource extends Object implements Resource
Resource that produces a InputStream from a classpath resource.
Author:
Middleware Services
  • Constructor Details

    • ClassPathResource

      public ClassPathResource(String path)
      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

      public ClassPathResource(String path, ClassLoader loader)
      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

      public InputStream 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 call InputStream.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 interface Resource
      Returns:
      Input stream around underlying resource, e.g. file, remote resource (URI), etc.