Java tutorial
//package com.java2s; import java.util.Map; import java.util.Set; public class Main { public static String map2Str(Map<String, String> map) { StringBuilder sb = new StringBuilder(""); Set<String> keys = map.keySet(); for (String key : keys) sb.append(key + ":" + map.get(key) + ", "); String s = sb.toString().trim(); if (!s.endsWith(",")) return s; else return s.substring(0, s.lastIndexOf(",") - 1); } }