@Override public Properties readProperties(URL url, String encoding) throws ApplicationConfigReaderException { Properties properties = new Properties(); try (Reader reader = new BufferedReader(new InputStreamReader(url.openStream(), encoding))) { properties.load(reader); } catch (Exception e) { throw new ApplicationConfigReaderException("Can't read properties file: " + url, e); } return properties; }
@Override public Properties readProperties(URL url, String encoding) throws ApplicationConfigReaderException { Properties properties = new Properties(); try (Reader reader = new BufferedReader(new InputStreamReader(url.openStream(), encoding))) { Toml toml = new Toml().read(reader); for (Map.Entry<String, Object> entry : toml.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Toml) { // section for (Map.Entry<String, Object> subEntry : ((Toml) value).entrySet()) { properties.put(key + "." + subEntry.getKey(), subEntry.getValue()); } } else { // simple property properties.put(key, value); } } } catch (Exception e) { throw new ApplicationConfigReaderException("Can't read toml file: " + url, e); } return properties; }
@Override public Properties readProperties(URL url, String encoding) throws ApplicationConfigReaderException { Properties properties = new Properties(); INIConfiguration iniConfiguration = new INIConfiguration(); try (Reader reader = new BufferedReader(new InputStreamReader(url.openStream(), encoding))) { iniConfiguration.read(reader); } catch (Exception e) { throw new ApplicationConfigReaderException("Can't read ini file: " + url, e); } Iterator<String> keysIterator = iniConfiguration.getKeys(); while (keysIterator.hasNext()) { String key = keysIterator.next(); properties.put(key, iniConfiguration.getProperty(key)); } for (String sectionName : iniConfiguration.getSections()) { if (sectionName == null) { continue; } SubnodeConfiguration section = iniConfiguration.getSection(sectionName); Iterator<String> sectionKeysIterator = section.getKeys(); while (sectionKeysIterator.hasNext()) { String key = sectionKeysIterator.next(); properties.put(sectionName + "." + key, section.getProperty(key)); } } return properties; }