org.umber.core.util
Class ResourceLoader

java.lang.Object
  extended byorg.umber.core.util.ResourceLoader

public class ResourceLoader
extends java.lang.Object

Convenience class to help loading Java resources.

Author:
jsheets

Constructor Summary
ResourceLoader()
           
 
Method Summary
static java.lang.String loadInputStreamAsString(java.io.InputStream in)
          Loads contents of an InputStream into a String.
static java.util.Properties loadResourceAsProperties(java.lang.String path)
          Loads a properties file at the given resource path.
static java.util.Properties loadResourceAsProperties(java.lang.String path, java.lang.Class resClass)
          Loads a properties file at the given resource path, absolute or relative from the given class.
static java.io.InputStream loadResourceAsStream(java.lang.String path)
          Loads a java resource as an InputStream.
static java.io.InputStream loadResourceAsStream(java.lang.String path, java.lang.Class resClass)
          Loads a java resource as an InputStream, absolute or relative from the given class.
static java.lang.String loadResourceAsString(java.lang.String path)
          Loads the contents of a java resource as a String.
static java.lang.String loadResourceAsString(java.lang.String path, java.lang.Class resClass)
          Loads the contents of a java resource as a String, absolute or relative from the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLoader

public ResourceLoader()
Method Detail

loadResourceAsStream

public static java.io.InputStream loadResourceAsStream(java.lang.String path)
Loads a java resource as an InputStream.

Parameters:
path - absolute path to resource
Returns:
stream of resource, or null if not found

loadResourceAsStream

public static java.io.InputStream loadResourceAsStream(java.lang.String path,
                                                       java.lang.Class resClass)
Loads a java resource as an InputStream, absolute or relative from the given class.

Parameters:
path - absolute or relative path to resource
resClass - class to use for loading resources
Returns:
stream of resource, or null if not found

loadResourceAsString

public static java.lang.String loadResourceAsString(java.lang.String path)
Loads the contents of a java resource as a String.

Parameters:
path - absolute path to resource
Returns:
contents of resource, or null if not found

loadResourceAsString

public static java.lang.String loadResourceAsString(java.lang.String path,
                                                    java.lang.Class resClass)
Loads the contents of a java resource as a String, absolute or relative from the given class.

Parameters:
path - absolute or relative path to resource
resClass - class to use for loading resources
Returns:
contents of resource, or null if not found

loadInputStreamAsString

public static java.lang.String loadInputStreamAsString(java.io.InputStream in)
Loads contents of an InputStream into a String. This method will read until the stream is empty; if an I/O error occurs, the returned String will be null.

Parameters:
in - InputStream
Returns:
stream contents, or null if error occurs

loadResourceAsProperties

public static java.util.Properties loadResourceAsProperties(java.lang.String path)
Loads a properties file at the given resource path.

Parameters:
path - absolute path to resource
Returns:
properties file, or null if not found

loadResourceAsProperties

public static java.util.Properties loadResourceAsProperties(java.lang.String path,
                                                            java.lang.Class resClass)
Loads a properties file at the given resource path, absolute or relative from the given class.

Parameters:
path - absolute or relative path to resource
resClass - class to use for loading resources
Returns:
properties file, or null if not found