Java Map to String mapToString(Map map)

Here you can find the source of mapToString(Map map)

Description

map To String

License

Open Source License

Declaration

public static String mapToString(Map<String, String> map) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;

public class Main {
    public static String mapToString(Map<String, String> map) {
        StringBuilder sb = new StringBuilder();

        sb.append("[");

        if (map != null && map.size() > 0) {
            int i = 0;
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (i + 1 == map.size()) {
                    sb.append(entry.getKey()).append("=").append(entry.getValue());
                } else {
                    sb.append(entry.getKey()).append("=").append(entry.getValue()).append(";");
                }//from  w  w w . j av  a 2s  . c om
                i++;
            }
        }

        sb.append("]");

        return sb.toString();
    }
}

Related

  1. mapToString(Map map)
  2. mapToString(Map map)
  3. mapToString(Map map)
  4. mapToString(Map map)
  5. MapToString(Map map)
  6. mapToString(Map parameterMap)
  7. mapToString(Map map, String splitter)
  8. mapToString(String aName, Map aMap, String aPrefix, String aSuffix, String aKeyValueSeparator, String anEntrySeparator, String anArrayPrefix, String anArraySuffix, String anArraySeparator, String anEscapeChars, char anEscapeSymbol)
  9. mapToString(String itemName, Map map)