Method to convert a ResourceBundle to a Properties object.
import java.util.Enumeration;
import java.util.Properties;
import java.util.ResourceBundle;
/**
* Utility class to convert one object to another.
*
* @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
*/
public final class Util {
/**
* Method to convert a ResourceBundle to a Properties object.
* @param rb a given resource bundle
* @return Properties a populated properties object
*/
public static Properties convertBundleToProperties(ResourceBundle rb) {
Properties props = new Properties();
for (Enumeration<String> keys = rb.getKeys(); keys.hasMoreElements();) {
String key = keys.nextElement();
props.put(key, rb.getString(key));
}
return props;
}
}
Related examples in the same category