Here you can find the source of map2String(Map
private static String map2String(Map<String, String> params)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; import java.util.Map.Entry; public class Main { private static String map2String(Map<String, String> params) { int count = 0; StringBuilder builder = new StringBuilder(); for (Entry<String, String> entry : params.entrySet()) { if (count > 0) { builder.append("&"); }//from www . j a v a2 s . c o m builder.append(entry.getKey()); builder.append("="); try { if (null == entry.getValue()) { builder.append(entry.getValue()); } else { builder.append(URLEncoder.encode(entry.getValue(), "utf-8")); } } catch (UnsupportedEncodingException e) { builder.append(entry.getValue()); } count++; } return builder.toString(); } }