List of usage examples for org.apache.commons.configuration.io FileHandler load
public void load() throws ConfigurationException
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 w w . j a va 2 s . 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; }
From source file:ubic.basecode.util.ConfigUtils.java
/** * @param file//from ww w . j ava 2 s .co m * @return * @throws ConfigurationException */ public static PropertiesConfiguration loadConfig(File file) throws ConfigurationException { if (!file.exists()) { try { FileTools.touch(file); } catch (IOException e) { throw new ConfigurationException("Couldn't create the file: " + e.getMessage()); } } PropertiesConfiguration pc = new PropertiesConfiguration(); FileHandler handler = new FileHandler(pc); handler.setFile(file); handler.load(); return pc; }
From source file:ubic.basecode.util.r.RServeClient.java
/** * @return// w w w .java2 s . c om * @throws ConfigurationException */ protected static String findRserveCommand() throws ConfigurationException { URL userSpecificConfigFileLocation = ConfigUtils.locate("local.properties"); PropertiesConfiguration userConfig = null; if (userSpecificConfigFileLocation != null) { userConfig = new PropertiesConfiguration(); FileHandler handler = new FileHandler(userConfig); handler.setFileName("local.properties"); handler.load(); } String rserveExecutable = null; if (userConfig != null) { rserveExecutable = userConfig.getString("rserve.start.command"); } if (StringUtils.isBlank(rserveExecutable)) { log.info("Rserve command not configured? Trying fallbacks"); if (os.startsWith("windows")) { // lower cased rserveExecutable = System.getenv("R_HOME") + File.separator + "library" + File.separator + "Rserve" + File.separator + "Rserve.exe"; } else { rserveExecutable = "R CMD Rserve"; } } return rserveExecutable; }