Here you can find the source of getParams(Map
public static String getParams(Map<String, String> params, String encode)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; public class Main { public static String getParams(Map<String, String> params, String encode) { StringBuffer stringBuffer = new StringBuffer(); if (params != null && !params.isEmpty()) { for (Map.Entry<String, String> entry : params.entrySet()) { try { if (entry.getValue() == null || "".equals(entry.getValue())) { stringBuffer.append(entry.getKey()).append("=") .append(entry.getValue()).append("&"); } else { stringBuffer//from ww w . j a v a 2 s.co m .append(entry.getKey()) .append("=") .append(URLEncoder.encode(entry.getValue(), encode)).append("&"); } } catch (UnsupportedEncodingException e) { stringBuffer = null; } } if (stringBuffer != null) { stringBuffer.deleteCharAt(stringBuffer.length() - 1); } } return stringBuffer.toString(); } }