Java URL Query Build toQueryString(Map requestMap)

Here you can find the source of toQueryString(Map requestMap)

Description

to Query String

License

Open Source License

Declaration

public static String toQueryString(Map<String, String> requestMap) throws UnsupportedEncodingException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;

public class Main {
    public static String toQueryString(Map<String, String> requestMap) throws UnsupportedEncodingException {
        String paramStr = "";
        for (Map.Entry<String, String> entry : requestMap.entrySet()) {
            if (!paramStr.isEmpty()) {
                paramStr += "&";
            }//  w w w  .  j a va2s  .c om
            paramStr += entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
        }
        return paramStr;
    }
}

Related

  1. getQueryValues(String input)
  2. mapToQueryString(Map parameters, String charSet)
  3. mapToQueryString(Map parameters, String charSet)
  4. mapToQueryString(Map queryString)
  5. toQueryString(Map map)