Java Utililty Methods URL Parameter Builder

List of utility methods to do URL Parameter Builder

Description

The list of methods to do URL Parameter Builder are organized into topic(s).

Method

MapparseParameters(final String value)
Parse the given application/x-www-form-urlencoded String and return the parameters as a (name/value) Map.
if (value == null || value.isEmpty()) {
    return Collections.emptyMap();
final Map<String, String> map = new HashMap<String, String>();
final Matcher m = KEY_VALUES.matcher(value);
while (m.find()) {
    map.put(decodeRfc5849(m.group(1)), decodeRfc5849(m.group(2)));
return map;
HashMapparseResponseParams(String body)
parse Response Params
HashMap<String, String> results = new HashMap<String, String>();
for (String keyValuePair : body.split("&")) {
    String[] kvp = keyValuePair.split("=");
    results.put(kvp[0], URLDecoder.decode(kvp[1], "UTF-8"));
return results;
booleansendGetRequest(String path, Map params, String enc)
send Get Request
StringBuilder sb = new StringBuilder(path);
sb.append('?');
for (Map.Entry<String, String> entry : params.entrySet()) {
    sb.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), enc)).append('&');
sb.deleteCharAt(sb.length() - 1);
URL url = new URL(sb.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
...
booleansendPostRequest(String path, Map params, String enc)
send Post Request
StringBuilder sb = new StringBuilder();
if (params != null && !params.isEmpty()) {
    for (Map.Entry<String, String> entry : params.entrySet()) {
        sb.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), enc)).append('&');
    sb.deleteCharAt(sb.length() - 1);
byte[] entitydata = sb.toString().getBytes();
...
StringserializeParameters(final Map parameters)
serialize Parameters
try {
    final StringBuilder sb = new StringBuilder();
    final Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator();
    if (iterator.hasNext()) {
        Map.Entry<String, String> entry;
        String key;
        String encodedKey;
        String value;
...
StringserializeParameters(final Map params)
Serialises the specified map of parameters into a URL query string.
if (params == null || params.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {
    if (entry.getKey() == null)
        continue;
    String value = entry.getValue() != null ? entry.getValue() : "";
    try {
...
MapstringToMap(String input)
string To Map
Map<String, Object> map = new HashMap<String, Object>();
String[] nameValuePairs = input.split("&");
for (String nameValuePair : nameValuePairs) {
    String[] nameValue = nameValuePair.split("=");
    try {
        if (isParsable(nameValue[1])) {
            map.put(URLDecoder.decode(nameValue[0], "UTF-8"), (int) Integer.parseInt(nameValue[1]));
        } else {
...
MapstringToMap(String input)
string To Map
Map<String, String> map = new HashMap<String, String>();
String[] nameValuePairs = input.split("&");
for (String nameValuePair : nameValuePairs) {
    String[] nameValue = nameValuePair.split("=");
    try {
        map.put(URLDecoder.decode(nameValue[0], "UTF-8"),
                nameValue.length > 1 ? URLDecoder.decode(nameValue[1], "UTF-8") : "");
    } catch (UnsupportedEncodingException e) {
...
StringstringUncode(String param)
string Uncode
if (param != null && !param.trim().equals("")) {
    try {
        param = URLDecoder.decode(param, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
return param;
...