Here you can find the source of createQueryStringForParameters(Map
public static String createQueryStringForParameters(Map<String, String> parameters)
//package com.java2s; //License from project: Open Source License import java.net.URLEncoder; import java.util.Map; public class Main { private static final char PARAMETER_DELIMITER = '&'; private static final char PARAMETER_EQUALS_CHAR = '='; public static String createQueryStringForParameters(Map<String, String> parameters) { StringBuilder parametersAsQueryString = new StringBuilder(); if (parameters != null) { boolean firstParameter = true; for (String parameterName : parameters.keySet()) { if (!firstParameter) { parametersAsQueryString.append(PARAMETER_DELIMITER); }/*from w w w .ja v a 2 s . c o m*/ parametersAsQueryString.append(parameterName).append(PARAMETER_EQUALS_CHAR) .append(URLEncoder.encode(parameters.get(parameterName))); firstParameter = false; } } return parametersAsQueryString.toString(); } }