Here you can find the source of toQueryString(Map
public static String toQueryString(Map<String, String> requestMap) throws UnsupportedEncodingException
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; public class Main { public static String toQueryString(Map<String, String> requestMap) throws UnsupportedEncodingException { String paramStr = ""; for (Map.Entry<String, String> entry : requestMap.entrySet()) { if (!paramStr.isEmpty()) { paramStr += "&"; }// w w w . j a va2s .c om paramStr += entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8"); } return paramStr; } }