List of usage examples for org.apache.commons.configuration HierarchicalINIConfiguration setEncoding
public void setEncoding(String encoding)
From source file:com.baasbox.db.DbHelper.java
public static void populateConfiguration() throws IOException, ConfigurationException { BaasBoxLogger.info("Load initial configuration..."); InputStream is;/*from w w w.ja v a2 s. c om*/ if (Play.application().isProd()) is = Play.application().resourceAsStream(CONFIGURATION_FILE_NAME); else is = new FileInputStream(Play.application().getFile("conf/" + CONFIGURATION_FILE_NAME)); HierarchicalINIConfiguration c = new HierarchicalINIConfiguration(); c.setEncoding("UTF-8"); c.load(is); CharSequence doubleDot = ".."; CharSequence dot = "."; Set<String> sections = c.getSections(); for (String section : sections) { Class en = PropertiesConfigurationHelper.CONFIGURATION_SECTIONS.get(section); if (en == null) { BaasBoxLogger.warn(section + " is not a valid configuration section, it will be skipped!"); continue; } SubnodeConfiguration subConf = c.getSection(section); Iterator<String> it = subConf.getKeys(); while (it.hasNext()) { String key = (it.next()); Object value = subConf.getString(key); key = key.replace(doubleDot, dot);//bug on the Apache library: if the key contain a dot, it will be doubled! try { BaasBoxLogger.info("Setting " + value + " to " + key); PropertiesConfigurationHelper.setByKey(en, key, value); } catch (Exception e) { BaasBoxLogger.warn("Error loading initial configuration: Section " + section + ", key: " + key + ", value: " + value, e); } } } is.close(); BaasBoxLogger.info("...done"); }