Here you can find the source of mapToString(Map, ?> map)
public static String mapToString(Map<?, ?> map)
//package com.java2s; //License from project: Open Source License import java.util.Map; public class Main { public static String mapToString(Map<?, ?> map) { //, String valueSeperator, String delimeter) { return mapToString(map, "=", ","); }/* www. ja v a 2 s.c o m*/ public static String mapToString(Map<?, ?> map, String valueSeperator, String delimeter) { return mapToString(map, "", "", valueSeperator, delimeter); } public static String mapToString(Map<?, ?> map, String keyWrap, String valWrap, String valueSeperator, String delimeter) { StringBuilder text = new StringBuilder(); for (Object key : map.keySet()) { Object value = map.get(key); text.append(keyWrap + key + keyWrap + valueSeperator + valWrap + value + valWrap + delimeter); } deleteLastDelimeter(text, delimeter); return text.toString(); } public static void deleteLastDelimeter(StringBuilder sb, String delimeter) { if (sb.length() > delimeter.length()) { sb.delete(sb.length() - delimeter.length(), sb.length()); } } }