I am able to convert org.apache.commons.configuration.Configuration
to java.util.Properties
using:
Properties props = new Properties();
Configuration config = new PropertiesConfiguration(fileName);
Iterator iter = config.getKeys();
while (iter.hasNext()) {
String key = (String) iter.next();
String value = config.getString(key);
props.put(key, value);
}
Assumption: keys and values are of String type.
Is there any direct way to convert Configuration
to Properties
?
ConfigurationConverter should do the job .
It has those two methods to convert in both directions :
Configuration getConfiguration(Properties props)
Convert a standard Properties class into a configuration class
and
Properties getProperties(Configuration config)
Convert a Configuration class into a Properties class.