Here you can find the source of mapToQueryString(Map
public static String mapToQueryString(Map<String, String> queryString) throws UnsupportedEncodingException
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; public class Main { public static final String ENCODING_UTF_8 = "UTF-8"; public static String mapToQueryString(Map<String, String> queryString) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> e : queryString.entrySet()) { if (sb.length() > 0) { sb.append('&'); }// ww w .ja va 2s. co m sb.append(URLEncoder.encode(e.getKey(), ENCODING_UTF_8)).append('=') .append(URLEncoder.encode(e.getValue(), "UTF-8")); } return sb.toString(); } }