org.apache.maven.archiva.common.utils
Class ResourceUtils

Package class diagram package ResourceUtils
java.lang.Object
  extended by org.apache.maven.archiva.common.utils.ResourceUtils

public class ResourceUtils
extends java.lang.Object

ResourceUtils


Constructor Summary
ResourceUtils()
           
 
Method Summary
static java.io.File getResource(java.lang.String resourcePath)
          Lookup resource at the given path relative to the root of the classpath and if it exists return a file object that can be used to access it.
static java.io.File getResource(java.lang.String resourcePath, java.lang.ClassLoader classloader)
          Lookup resource at the given path relative to the root of the classpath and if it exists return a file object that can be used to access it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceUtils

public ResourceUtils()
Method Detail

getResource

public static java.io.File getResource(java.lang.String resourcePath)
                                throws java.io.IOException
Lookup resource at the given path relative to the root of the classpath and if it exists return a file object that can be used to access it.

At test time the contents of both the src/resources and test/resources dirs are available at the root of the classpath.

To retrieve the file src/test/resources/sometest/test.properties use getResource("/sometest/test.properties").

Parameters:
resourcePath - the path to the resource relative to the root of the classpath
Returns:
File a file object pointing to the resource on the classpath or null if the resource cannot be found
Throws:
java.io.IOException

getResource

public static java.io.File getResource(java.lang.String resourcePath,
                                       java.lang.ClassLoader classloader)
                                throws java.io.IOException
Lookup resource at the given path relative to the root of the classpath and if it exists return a file object that can be used to access it.

At test time the contents of both the src/resources and test/resources dirs are available at the root of the classpath.

To retrieve the file src/test/resources/sometest/test.properties use getResource("/sometest/test.properties").

Parameters:
resourcePath - the path to the resource relative to the root of the classpath
classloader - the classloader who's classpath should be searched for the resource
Returns:
File a file object pointing to the resource on the classpath or null if the resource cannot be found
Throws:
java.io.IOException