Here you can find the source of toStringMap(Map, ?> src)
public static Map<String, String> toStringMap(Map<?, ?> src)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { public static Map<String, String> toStringMap(Map<?, ?> src) { Map<String, String> dst = new HashMap<String, String>(); Set<?> entrySet = src.entrySet(); for (Object object : entrySet) { if (object != null && object instanceof Entry<?, ?>) { Entry<?, ?> entry = (Entry<?, ?>) object; Object key = entry.getKey(); Object value = entry.getValue(); if (key != null) { if (value == null) { value = ""; }//from w ww.j a va 2s .co m dst.put(key.toString(), value.toString()); } } } return dst; } public static String toString(Map<?, ?> src, String format) { if (src != null && src.size() > 0) { Set<?> keySet = src.keySet(); for (Object key : keySet) { if (key != null) { Object value = src.get(key); if (value != null) { format = format.replaceAll("\\{" + key.toString() + "\\}", value.toString()); } } } } else { return null; } return format; } }