Java URL Parameter Builder convertToParameterString(Map parameterMap)

Here you can find the source of convertToParameterString(Map parameterMap)

Description

convert To Parameter String

License

Open Source License

Declaration

public static String convertToParameterString(Map<String, Object> parameterMap) 

Method Source Code

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

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;
import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static String convertToParameterString(Map<String, Object> parameterMap) {
        StringBuilder returnValue = new StringBuilder();

        if (parameterMap != null) {
            try {
                for (Entry<String, Object> entry : parameterMap.entrySet()) {
                    if (returnValue.length() > 0)
                        returnValue.append("&");
                    returnValue.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
                    returnValue.append("=");
                    if (entry.getValue() != null)
                        returnValue.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
                }//from  w  w w.ja  va2 s .  c om
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        return returnValue.toString();
    }
}

Related

  1. canonicalize(final SortedMap sortedParamMap)
  2. canonicalize(final SortedMap sortedParamMap)
  3. constructParameterString(TreeMap pPostParms)
  4. convertHttpParameters(Map parameters)
  5. convertToDataString(Map data)
  6. extractParameters(String parameterString)
  7. format(final Map> parameters, final String encoding)
  8. format(Map parameters, final String encoding)
  9. getParameter(String source, int index)