Here you can find the source of loadCorrectedConfiguration(String configurationFilename)
public static Properties loadCorrectedConfiguration(String configurationFilename)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.net.URLDecoder; import java.util.Properties; public class Main { public static Properties loadCorrectedConfiguration(String configurationFilename) { try {//w w w .java2 s .co m // Use -Drepox.data.dir= in the VM parameters in order to pass an already existing configuration.properties and gui.properties String configsDataDir = System.getProperty("repox.data.dir"); String configurationFile; if (configDataDirAlreadyExists(configsDataDir, configurationFilename)) configurationFile = URLDecoder.decode(configsDataDir + File.separator + configurationFilename, "ISO-8859-1"); else { URL configurationURL = Thread.currentThread().getContextClassLoader() .getResource(configurationFilename); configurationFile = URLDecoder.decode(configurationURL.getFile(), "ISO-8859-1"); } Properties properties = new Properties(); properties.load(new FileInputStream(configurationFile)); return properties; } catch (Exception e) { throw new IllegalArgumentException("could not load [" + configurationFilename + "]"); } } public static boolean configDataDirAlreadyExists(String configsDataDir, String configurationFilename) { if (configsDataDir == null || configsDataDir.isEmpty()) return false; File configFile = new File(configsDataDir + File.separator + configurationFilename); if (!configFile.exists()) { System.out.println("Load Config files from Java Variables -- " + configurationFilename + " file doesn't exist on the specified directory"); return false; } return true; } }