Example usage for org.apache.commons.configuration.io FileHandler setURL

List of usage examples for org.apache.commons.configuration.io FileHandler setURL

Introduction

In this page you can find the example usage for org.apache.commons.configuration.io FileHandler setURL.

Prototype

public void setURL(final URL url) 

Source Link

Document

Sets the location of the associated file as a URL.

Usage

From source file:ubic.basecode.util.ConfigUtils.java

/**
 * @param name the classpath location, such as "project.properties" in the base package, or
 *        org/foo/project.properties.//from  w  ww .  j  ava2s . c  o  m
 * @return
 * @throws ConfigurationException
 */
public static PropertiesConfiguration loadClasspathConfig(String name) throws ConfigurationException {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    URL url = loader.getResource(name);
    if (url == null) {
        throw new ConfigurationException("Couldn't locate: " + name);
    }

    PropertiesConfiguration pc = new PropertiesConfiguration();
    FileHandler handler = new FileHandler(pc);
    handler.setURL(url);
    handler.load();
    return pc;
}