org.apache.camel.util
Class ResourceHelper

java.lang.Object
  extended by org.apache.camel.util.ResourceHelper

public final class ResourceHelper
extends Object

Helper for loading resources on the classpath or file system.


Method Summary
static InputStream resolveMandatoryResourceAsInputStream(ClassResolver classResolver, String uri)
          Resolves the mandatory resource.
static URL resolveMandatoryResourceAsUrl(ClassResolver classResolver, String uri)
          Resolves the mandatory resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveMandatoryResourceAsInputStream

public static InputStream resolveMandatoryResourceAsInputStream(ClassResolver classResolver,
                                                                String uri)
                                                         throws IOException
Resolves the mandatory resource.

If possible prefer to use resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String) if possible.

Parameters:
classResolver - the class resolver to load the resource from the classpath
uri - uri of the resource
Returns:
the resource as an InputStream, remember to close the stream after usage.
Throws:
IOException - is thrown if the resource file could not be found or loaded as InputStream

resolveMandatoryResourceAsUrl

public static URL resolveMandatoryResourceAsUrl(ClassResolver classResolver,
                                                String uri)
                                         throws FileNotFoundException,
                                                MalformedURLException
Resolves the mandatory resource.

Parameters:
classResolver - the class resolver to load the resource from the classpath
uri - uri of the resource
Returns:
the resource as an InputStream, remember to close the stream after usage.
Throws:
FileNotFoundException - is thrown if the resource file could not be found
MalformedURLException - if the uri is malformed


Apache CAMEL