Convert a Properties list into a map.
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
public class Main {
public static void main(String args[]) {
Properties prop = new Properties();
prop.setProperty("A", "t@h.com");
prop.setProperty("B", "k@h.com");
prop.setProperty("C", "R@h.com");
prop.setProperty("D", "S@h.com");
HashMap<String, String> propMap = new HashMap<String, String>((Map) prop);
Set<Map.Entry<String, String>> propSet;
propSet = propMap.entrySet();
System.out.println("Contents of map: ");
for (Map.Entry<String, String> me : propSet) {
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
}
}
Related examples in the same category