Interface Resource


public interface Resource
Describes a loadable resource such as a file, classpath entry, or HTTP URL.

A resource abstracts over its backing location: it exposes the scheme (file, classpath, http, and so on), the location, whether it exists(), and provides fresh streams or readers on each call. Camel loads routes, scripts, and other artifacts through resources. Instances are obtained from a ResourceLoader, which delegates to a scheme-specific ResourceResolver.

Since:
3.8
See Also:
  • Method Details

    • getScheme

      String getScheme()
      The scheme of the resource such as file, classpath, or http.
      Returns:
      the scheme
    • getLocation

      String getLocation()
      The location of the resource.
      Returns:
      the location
    • exists

      boolean exists()
      Whether this resource exists.
      Returns:
      true if the resource exists
    • getURI

      default URI getURI()
      The URI of the resource.

      The default implementation creates a URI object from resource location.
    • getURL

      default @Nullable URL getURL() throws MalformedURLException
      The URL for the resource or null if the URL can not be computed.

      The default implementation creates a URI object from resource location.
      Throws:
      MalformedURLException
    • getInputStream

      InputStream getInputStream() throws IOException
      Returns an InputStream that reads from the underlying resource.

      Each invocation must return a new InputStream instance.
      Throws:
      IOException
    • getReader

      default Reader getReader() throws Exception
      Returns a Reader that reads from the underlying resource using UTF-8 as charset.

      Each invocation must return a new Reader.
      Throws:
      Exception
      See Also:
    • getReader

      default Reader getReader(Charset charset) throws Exception
      Returns a Reader that reads from the underlying resource using the given Charset

      Each invocation must return a new Reader.
      Throws:
      Exception
      See Also: