Java Utililty Methods Map to Properties

List of utility methods to do Map to Properties

Description

The list of methods to do Map to Properties are organized into topic(s).

Method

PropertiesmapToProperties(Map params)
map To Properties
Properties p = new Properties();
for (Iterator iterator = params.keySet().iterator(); iterator.hasNext();) {
    String name = (String) iterator.next();
    String value = (String) params.get(name);
    if (value != null) {
        p.setProperty(name, value);
return p;
StringmapToProperties(Map propertyMap)
Convert string of comma separated properties to a map.
StringBuilder propertyBuilder = new StringBuilder();
boolean hasAtLeastOneKey = false;
for (String key : propertyMap.keySet()) {
    if (hasAtLeastOneKey) {
        propertyBuilder.append(", ");
    if (!key.isEmpty()) {
        hasAtLeastOneKey = true;
...
String[]mapToProperties(Map map)
Converts a map into an array of strings.
if (map == null)
    return null;
String[] properties = new String[map.size() * 2];
int counter = 0;
for (Map.Entry<String, String> entry : map.entrySet()) {
    properties[counter++] = entry.getKey();
    properties[counter++] = entry.getValue();
return properties;