Here you can find the source of buildQuery(Map
public static String buildQuery(Map<String, Object> query)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; public class Main { public static String buildQuery(Map<String, Object> query) { if (query == null) { return ""; } else {//from ww w . j av a 2s .c om StringBuilder builder = new StringBuilder(); Iterator<Entry<String, Object>> it = query.entrySet().iterator(); while (it.hasNext()) { Entry<String, Object> entry = it.next(); if (builder.length() > 0) { builder.append("&"); } try { builder.append(URLEncoder.encode(entry.getKey(), "UTF-8")); } catch (UnsupportedEncodingException e) { } if (entry.getValue() != null) { builder.append("="); try { builder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8")); } catch (UnsupportedEncodingException e) { } } } return builder.toString(); } } }