Here you can find the source of getQueryString(Map
public static String getQueryString(Map<String, Object> parameters)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; import java.util.Map.Entry; public class Main { public static String getQueryString(Map<String, Object> parameters) { if (parameters != null) { StringBuilder result = new StringBuilder(); boolean isFirst = true; for (Entry<String, Object> entry : parameters.entrySet()) { if (!(entry.getValue() instanceof File)) { if (!isFirst) { result.append("&"); }//from www. j ava 2 s. c o m result.append(entry.getKey()).append("=").append(encodeParameter(entry.getValue().toString())); if (isFirst) isFirst = false; } } return result.toString(); } return ""; } public static String encodeParameter(String value) { if (value != null) { try { return URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } return ""; } }