org.ujac.util.io
Class ClassPathResourceLoader

java.lang.Object
  extended by org.ujac.util.io.ClassPathResourceLoader
All Implemented Interfaces:
ResourceLoader

public class ClassPathResourceLoader
extends Object
implements ResourceLoader

Title: ClassPathResourceLoader
Description: A resource loader which loads resources from the given class loader.

Author:
lauerc

Field Summary
static int IO_BUFFER_SIZE
          The I/O buffer size.
 
Constructor Summary
ClassPathResourceLoader(ClassLoader classLoader)
          Constructs a ClassPathResourceLoader instance with specific attributes.
ClassPathResourceLoader(ClassLoader classLoader, String pathPrefix)
          Constructs a ClassPathResourceLoader instance with specific attributes.
 
Method Summary
 byte[] loadResource(String location)
          Loads a binary resource from the class loader.
 boolean resourceExists(String location)
          Checks whether or not the desired resource exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IO_BUFFER_SIZE

public static final int IO_BUFFER_SIZE
The I/O buffer size.

See Also:
Constant Field Values
Constructor Detail

ClassPathResourceLoader

public ClassPathResourceLoader(ClassLoader classLoader)
                        throws IOException
Constructs a ClassPathResourceLoader instance with specific attributes.

Parameters:
classLoader - The class loader.
Throws:
IOException - If the given rootDirectory does not exist or is no directory.

ClassPathResourceLoader

public ClassPathResourceLoader(ClassLoader classLoader,
                               String pathPrefix)
                        throws IOException
Constructs a ClassPathResourceLoader instance with specific attributes.

Parameters:
classLoader - The class loader.
pathPrefix - The path prefix to prepend before the location.
Throws:
IOException - If the given rootDirectory does not exist or is no directory.
Method Detail

loadResource

public byte[] loadResource(String location)
                    throws IOException
Loads a binary resource from the class loader.

Specified by:
loadResource in interface ResourceLoader
Parameters:
location - The location of the resource.
Returns:
The loaded resource.
Throws:
IOException - In case the loading of the resource failed.

resourceExists

public boolean resourceExists(String location)
Checks whether or not the desired resource exists.

Specified by:
resourceExists in interface ResourceLoader
Parameters:
location - The location of the resource.
Returns:
true in case the given resource could be located, else false.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.