Java URL Build buildQuery(Map paramMap)

Here you can find the source of buildQuery(Map paramMap)

Description

build Query

License

Apache License

Declaration

public static String buildQuery(Map<String, Object> paramMap) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

import java.util.Map;

public class Main {
    public static String buildQuery(Map<String, Object> paramMap) {
        StringBuilder localStringBuilder = new StringBuilder();

        for (Map.Entry<String, Object> localEntry : paramMap.entrySet()) {
            if (localStringBuilder.length() > 0) {
                localStringBuilder.append('&');
            }/* ww  w . j av a 2  s .  c  o  m*/
            try {
                localStringBuilder.append(URLEncoder.encode((String) localEntry.getKey(), "UTF-8"));
            } catch (UnsupportedEncodingException localUnsupportedEncodingException1) {
                localUnsupportedEncodingException1.printStackTrace();
            }

            if (localEntry.getValue() != null) {
                localStringBuilder.append('=');
                try {
                    localStringBuilder.append(URLEncoder.encode(localEntry.getValue().toString(), "UTF-8"));
                } catch (UnsupportedEncodingException localUnsupportedEncodingException2) {
                    localUnsupportedEncodingException2.printStackTrace();
                }
            }
        }

        return localStringBuilder.toString();
    }
}

Related

  1. buildQuery(final Map query)
  2. buildQuery(final Map query)
  3. buildQuery(Map paramMap)
  4. buildQuery(Map query)
  5. buildQuery(Map params)
  6. buildQueryString(Map parameters)
  7. buildQueryString(Map params)