Here you can find the source of queryStringify(HashMap
Parameter | Description |
---|---|
qString | the map to convert |
private static String queryStringify(HashMap<String, String> qString)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; public class Main { /**/*from w w w .ja v a2 s.c om*/ * Converts a Map into an HTTP query string * @param qString the map to convert * @return the converted query string */ private static String queryStringify(HashMap<String, String> qString) { String retval = ""; for (Map.Entry<String, String> pair : qString.entrySet()) { try { retval += URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"); retval += "&"; } catch (UnsupportedEncodingException e) { throw new RuntimeException("Apparently Unicode isn't a good encoding"); } } // Remove last extra ampersand retval = retval.substring(0, retval.length() - 1); return retval; } }