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 Summary
Modifier and TypeMethodDescriptionbooleanexists()Whether this resource exists.Returns anInputStreamthat reads from the underlying resource.The location of the resource.default ReaderReturns aReaderthat reads from the underlying resource using UTF-8 as charset.default ReaderThe scheme of the resource such as file, classpath, or http.default URIgetURI()TheURIof the resource.default @Nullable URLgetURL()TheURLfor the resource ornullif the URL can not be computed.
-
Method Details
-
getScheme
-
getLocation
-
exists
boolean exists()Whether this resource exists.- Returns:
- true if the resource exists
-
getURI
-
getURL
TheURLfor the resource ornullif the URL can not be computed. The default implementation creates aURIobject from resource location.- Throws:
MalformedURLException
-
getInputStream
Returns anInputStreamthat reads from the underlying resource. Each invocation must return a newInputStreaminstance.- Throws:
IOException
-
getReader
-
getReader
-