Here you can find the source of toMap(Properties sourceProperties)
Parameter | Description |
---|---|
sourceProperties | Properties representing properties key-value map. |
public static Map<String, String> toMap(Properties sourceProperties)
//package com.java2s; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; public class Main { /**// w w w. j ava 2s . c o m * Make a Map<String, String> from the supplied Properties, * copying all the keys and values. * * @param sourceProperties Properties representing properties key-value map. * @return a Map<String, String> representation of the source * Properties. */ public static Map<String, String> toMap(Properties sourceProperties) { if (sourceProperties == null) { return null; } Map<String, String> configMap = new HashMap<String, String>(); Iterator<?> iter = sourceProperties.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); configMap.put(key, sourceProperties.getProperty(key)); } return configMap; } }