Java String Encode encodeParams(Map nameValuePairs)

Here you can find the source of encodeParams(Map nameValuePairs)

Description

encode Params

License

Open Source License

Declaration

public static String encodeParams(Map nameValuePairs) 

Method Source Code

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

import java.net.*;
import java.util.*;

public class Main {
    public static String encodeParams(Map nameValuePairs) {
        StringBuffer params = new StringBuffer();
        Iterator nvp = nameValuePairs.keySet().iterator();
        String name, value;/*from   w  w w.ja va 2  s  .  com*/
        char ch;

        while (nvp.hasNext()) {
            name = (String) nvp.next();
            value = (String) nameValuePairs.get(name);
            if (value == null)
                value = "null";
            if (nvp.hasNext())
                ch = '&';
            else
                ch = '\n';
            params.append(name + "=" + URLEncoder.encode(value) + ch);
        }

        return params.toString();
    }
}

Related

  1. encodeParameter(String key, String value)
  2. encodeParameters(Map> parameters)
  3. encodeParameters(Map parameters)
  4. encodeParameters(Map params, String paramsEncoding)
  5. encodeParams(final Map params)
  6. encodeParams(String encoding, String... params)
  7. EncodePath(String path)
  8. encodePath(String path)
  9. encodePath(String str)