Here you can find the source of mapToQueryString( HashMap
public static final String mapToQueryString( HashMap<String, String> queryString)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashMap; public class Main { public static final String mapToQueryString( HashMap<String, String> queryString) { StringBuilder sb = new StringBuilder(); try {/* w w w.j a v a2 s . co m*/ for (HashMap.Entry<String, String> e : queryString.entrySet()) { if (sb.length() > 0) { sb.append('&'); } sb.append(URLEncoder.encode(e.getKey(), "UTF-8")) .append('=') .append(URLEncoder.encode(e.getValue(), "UTF-8")); } } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } return sb.toString(); } }