Here you can find the source of mapToString(Map
public static <T> String mapToString(Map<String, T> map, String splitter)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> String mapToString(Map<String, T> map, String splitter) { if (map.size() == 0) return ""; Iterator iterator = map.keySet().iterator(); String key = (String) iterator.next(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(key);//w w w . ja v a 2 s . c o m stringBuilder.append(":"); stringBuilder.append(map.get(key)); while (iterator.hasNext()) { key = (String) iterator.next(); stringBuilder.append(splitter); stringBuilder.append(key); stringBuilder.append(":"); stringBuilder.append(map.get(key)); } return stringBuilder.toString(); } public static <T> String mapToString(Map<String, T> map) { return mapToString(map, ", "); } }