Here you can find the source of copyPropertiesToMap(Properties source, Map
Parameter | Description |
---|---|
source | The source properties |
target | The target map to populate |
public static void copyPropertiesToMap(Properties source, Map<String, String> target)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; public class Main { /**/*w w w .ja v a 2 s . c o m*/ * This function copies all mappings from source properties to target map. * * @param source * The source properties * @param target * The target map to populate */ public static void copyPropertiesToMap(Properties source, Map<String, String> target) { if (source != null) { //convert to map Iterator<Entry<Object, Object>> iterator = source.entrySet() .iterator(); Entry<Object, Object> entry = null; String key = null; String value = null; while (iterator.hasNext()) { //get next entry entry = iterator.next(); //get next key/value key = (String) entry.getKey(); value = (String) entry.getValue(); //put in map target.put(key, value); } } } }