org.apache.shindig.common.util
Class ResourceLoader

java.lang.Object
  extended by org.apache.shindig.common.util.ResourceLoader

public final class ResourceLoader
extends Object

Handles loading contents from resource and file system files.


Method Summary
static String getContent(File file)
           
static String getContent(String resource)
          Reads the contents of a resource as a string.
static InputStream open(String path)
          Opens a given path as either a resource or a file, depending on the path name.
static InputStream openResource(String resource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

open

public static InputStream open(String path)
                        throws IOException
Opens a given path as either a resource or a file, depending on the path name. If path starts with res://, we interpret it as a resource. Otherwise we attempt to load it as a file.

Parameters:
path -
Returns:
The opened input stream
Throws:
IOException

openResource

public static InputStream openResource(String resource)
                                throws IOException
Parameters:
resource -
Returns:
An input stream for the given named resource
Throws:
FileNotFoundException
IOException

getContent

public static String getContent(String resource)
                         throws IOException
Reads the contents of a resource as a string.

Parameters:
resource -
Returns:
Contents of the resource.
Throws:
IOException

getContent

public static String getContent(File file)
                         throws IOException
Parameters:
file -
Returns:
The contents of the file (assumed to be UTF-8).
Throws:
IOException


Copyright © 2007-2012. All Rights Reserved.