Create Url Params from Map - Android java.net

Android examples for java.net:URL

Description

Create Url Params from Map

Demo Code

import android.widget.EditText;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String getUrlParamsByMap(Map<String, Object> map) {
        if (map == null) {
            return "";
        }//from  w  w w. jav a 2s.  co  m
        StringBuffer sb = new StringBuffer();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            sb.append(entry.getKey() + "=" + entry.getValue());
            sb.append("&");
        }
        return sb.toString();
    }

}

Related Tutorials