Here you can find the source of mapToProperties(Map
Parameter | Description |
---|---|
properties | a parameter |
public static String mapToProperties(Map<String, Object> propertyMap)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { /**/*from w w w. jav a2 s. c o m*/ * Convert string of comma separated properties to a map. * * <p> * Any value will be converted by default to string using {@link #toString()}. * </p> * * @param properties */ public static String mapToProperties(Map<String, Object> propertyMap) { StringBuilder propertyBuilder = new StringBuilder(); boolean hasAtLeastOneKey = false; for (String key : propertyMap.keySet()) { if (hasAtLeastOneKey) { propertyBuilder.append(", "); } if (!key.isEmpty()) { hasAtLeastOneKey = true; propertyBuilder.append(key); if (propertyMap.get(key) != null) { propertyBuilder.append("=").append(propertyMap.get(key).toString().trim()); } } } return propertyBuilder.toString(); } }