org.infoglue.cms.util
Class ResourceHelper

java.lang.Object
  |
  +--org.infoglue.cms.util.ResourceHelper

public class ResourceHelper
extends java.lang.Object

Utility class for loading/manipulating resources (must be accessible from the classpath).

Author:
Patrik Nyborg

Method Summary
static java.io.InputStream getResourceAsStream(java.lang.String resourceName, java.lang.Class callingClass)
          Find a resource with a variety of fallback ClassLoaders.
static java.util.Properties loadProperties(java.lang.String name)
          Loads the specified property file into a Properties object.
static java.lang.String readResource(java.lang.String name)
          Loads the specified resource file and returns the content as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadProperties

public static java.util.Properties loadProperties(java.lang.String name)

Loads the specified property file into a Properties object.

Example: ResourceHelper.loadProperties("se/sprawl/cms/CMSProperties.properties");

Parameters:
name - the name of the resource ("/"-separated path name).

readResource

public static java.lang.String readResource(java.lang.String name)

Loads the specified resource file and returns the content as a string.

Example: ResourceHelper.readResource("se/sprawl/cms/CMSSQL.sql");

Parameters:
name - the name of the resource ("/"-separated path name).

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resourceName,
                                                      java.lang.Class callingClass)
Find a resource with a variety of fallback ClassLoaders.

Parameters:
resourceName - The name of the resource to find. ("/"-separated path name)
callingClass - The class looking for the resource
Returns:
The InputStream for the given resource name, or null if one is not found