Here you can find the source of mapToString(Map
public static String mapToString(Map<String, String> map)
//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(); } }