List of utility methods to do URL Encode
String | encode(String s) encode return URLEncoder.encode(s);
|
ArrayList | encodeParams(ArrayList encode Params ArrayList<String> encoded = new ArrayList<String>(); for (String string : params) { String[] parts = string.split("="); if (parts.length == 2) { encoded.add(parts[0] + "=" + URLEncoder.encode(parts[1], "UTF-8")); } else { encoded.add(string); ... |
String | encodeUrl(Bundle parameters) encode Url if (parameters == null) { return ""; try { StringBuilder sb = new StringBuilder(); boolean first = true; for (String key : parameters.keySet()) { if (first) ... |
String | encodeUriSegment(String segment) encode Uri Segment try { return URLEncoder.encode(segment, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); |
String | encodeUrl(Bundle parameters) encode Url if (parameters == null) { return ""; StringBuilder sb = new StringBuilder(); boolean first = true; for (String key : parameters.keySet()) { if (first) { first = false; ... |
String | encodeUrlParam(String s) encode Url Param try { return URLEncoder.encode(s.replace("/", "%2F"), "UTF-8") .replace("+", "%20"); } catch (UnsupportedEncodingException e) { return s; |
String | weakUrlEncode(String url) Doesn't encode characters such as: ":", ";", etc. if (url == null) return null; String[] reserved = { ";", "?", " ", "&", "=", "$", ",", "[", "]", "#", "!", "'", "(", ")", "*" }; String[] escaped = { "%3B", "%3F", "+", "%26", "%3D", "%24", "%2C", "%5B", "%5D", "%21", "%27", "%28", "%28", "%29", "%2A" }; StringBuilder encUrl = new StringBuilder(url); for (int i = 0; i < escaped.length; i++) { ... |
String | encode(String s) encode if (s == null) { return ""; try { return URLEncoder.encode(s, "UTF-8").replace("+", "%20") .replace("*", "%2A").replace("%7E", "~") .replace("#", "%23"); } catch (UnsupportedEncodingException e) { ... |
String | getParams(Map get Params StringBuffer stringBuffer = new StringBuffer(); if (params != null && !params.isEmpty()) { for (Map.Entry<String, String> entry : params.entrySet()) { try { if (entry.getValue() == null || "".equals(entry.getValue())) { stringBuffer.append(entry.getKey()).append("=") .append(entry.getValue()).append("&"); ... |
String | encodeParameters(Map encode Parameters StringBuilder body = new StringBuilder(); Iterator<Entry<String, String>> it = params.entrySet().iterator(); boolean firstElement = true; while (it.hasNext()) { Map.Entry<String, String> pair = it.next(); if (firstElement) { firstElement = false; } else { ... |