de.enough.polish.util
Class ResourceUtil

java.lang.Object
  extended by de.enough.polish.util.ResourceUtil

public final class ResourceUtil
extends Object

Loads resources either from the disk or from the jar file.

Copyright Enough Software 2004 - 2011

 history
        15-Apr-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Constructor Summary
ResourceUtil(ClassLoader classLoader)
           
 
Method Summary
 InputStream open(File baseDir, String url)
          Opens the specified resource.
 InputStream open(String baseDir, String url)
          Opens the specified resource.
 String[] readTextFile(String baseDir, String url)
          Reads the specified text file and returns its content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceUtil

public ResourceUtil(ClassLoader classLoader)
Method Detail

open

public InputStream open(String baseDir,
                        String url)
                 throws FileNotFoundException
Opens the specified resource. The caller needs to ensure that the resource is closed.

Parameters:
baseDir - the base directory
url - the url to the resource, a '/'-separated path
Returns:
the InputStream for the specified resource.
Throws:
FileNotFoundException - when the specified resource could not be found

open

public InputStream open(File baseDir,
                        String url)
                 throws FileNotFoundException
Opens the specified resource. The caller needs to ensure that the resource is closed.

Parameters:
baseDir - the base directory
url - the url to the resource, a '/'-separated path
Returns:
the InputStream for the specified resource.
Throws:
FileNotFoundException - when the specified resource could not be found

readTextFile

public String[] readTextFile(String baseDir,
                             String url)
                      throws FileNotFoundException,
                             IOException
Reads the specified text file and returns its content.

Parameters:
baseDir - the base directory containing the resource
url - the URL to the text file.
Returns:
a String array with the content of the specified file.
Throws:
FileNotFoundException - when the specified resource could not be found
IOException - when the resource could not be read