Here you can find the source of buildUrlParameterString( List
public static String buildUrlParameterString( List<Pair<String, String>> parameters) throws UnsupportedEncodingException
//package com.java2s; import android.util.Pair; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; public class Main { /** Shorthand for building a parameter string used in the url of GET requests; */ public static String buildUrlParameterString( List<Pair<String, String>> parameters) throws UnsupportedEncodingException { return buildParameterString(parameters, "&", false); }//from w ww.jav a 2 s.c o m /** Builds a parameter string based on the given parameters, separated by given delimiter, and optionally quoted values */ public static String buildParameterString( List<Pair<String, String>> parameters, String delimiter, boolean quote) throws UnsupportedEncodingException { if (parameters == null || parameters.isEmpty()) return ""; StringBuilder builder = new StringBuilder(); for (int i = 0; i < parameters.size(); i++) { String key = parameters.get(i).first; String value = parameters.get(i).second; // skip 'null' values if (value == null) continue; String a = URLEncoder.encode(key, "UTF-8"); String b = URLEncoder.encode(value, "UTF-8"); builder.append(a + "="); // append key + "=" if (quote) builder.append("\""); // optionally append quote builder.append(b); // append value if (quote) builder.append("\""); // optionally append quote if (i != parameters.size() - 1) builder.append(delimiter); } return builder.toString(); } }