Here you can find the source of mapToFormString(Map
private static String mapToFormString(Map<String, String> map)
//package com.java2s; //License from project: Open Source License import java.net.URLEncoder; import java.util.Map; public class Main { private static String mapToFormString(Map<String, String> map) { StringBuilder postDataStringBuilder = new StringBuilder(); String postDataString;//from w w w .jav a 2 s. co m try { for (Map.Entry<String, String> entry : map.entrySet()) { postDataStringBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=") .append(URLEncoder.encode(entry.getValue(), "UTF-8")).append("&"); } } catch (Exception e) { } finally { postDataString = postDataStringBuilder.toString(); } return postDataString; } }