Android URL Create mapToQueryString( HashMap queryString)

Here you can find the source of mapToQueryString( HashMap queryString)

Description

map To Query String

License

Open Source License

Declaration

public static final String mapToQueryString(
            HashMap<String, String> queryString) 

Method Source Code

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

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

public class Main {
    public static final String mapToQueryString(
            HashMap<String, String> queryString) {
        StringBuilder sb = new StringBuilder();
        try {/*  w  w w.j  a v a2  s . co  m*/
            for (HashMap.Entry<String, String> e : queryString.entrySet()) {
                if (sb.length() > 0) {
                    sb.append('&');
                }
                sb.append(URLEncoder.encode(e.getKey(), "UTF-8"))
                        .append('=')
                        .append(URLEncoder.encode(e.getValue(), "UTF-8"));
            }
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        return sb.toString();
    }
}

Related

  1. generateQueryJson(Map params)
  2. generateQueryString(Map params)
  3. buildQueries(String baseQuery, List datesByQueryIndex)
  4. buildEmailUri(String email, String subject, CharSequence body)
  5. url(String baseUrl, String relativePath)
  6. url(String baseUrl, String relativePath)