Interface ResourceHandle


public interface ResourceHandle
Represents a handle to a locatable resource.
  • Method Details

    • getResolver

      ResourceResolver getResolver()
      Returns the resolver associated with this handle. Is usually the ResourceResolver.inModule(java.lang.Class<?>) for internal resources.
      Returns:
      The resolver.
    • getUrl

      URL getUrl()
      Gets the URL associated with this resource. With internal resources this is usually the result of Class.getResource(String)
      Returns:
      The URL.
    • exists

      default boolean exists()
      If the resource exists and is available.
      Returns:
      If it does.
    • isDirectory

      default boolean isDirectory()
      If the resource is a directory.
      Returns:
      If it is.
    • in

      default InputStream in() throws IOException
      Opens an input stream to the resource. Won't work for obscure resources that can't be read.
      Returns:
      The input stream.
      Throws:
      IOException
    • out

      default OutputStream out() throws IOException
      Opens an output stream to the resource. Won't work for resources that can't be written to like module resources.
      Returns:
      The output stream.
      Throws:
      IOException
    • ofModuleResource

      static ResourceHandle ofModuleResource(String path)
    • ofModuleResource

      static ResourceHandle ofModuleResource(Class<?> klass, String path)
    • ofFile

      static ResourceHandle ofFile(String path)