List of utility methods to do URI Encode
String | encodeUri(String uri) encode Uri int quoIndex = uri.indexOf("?"); if (quoIndex < 0 || quoIndex == uri.length()) { return uri; String url = uri.substring(0, quoIndex); String param = uri.substring(quoIndex + 1); String encodedUri = uri; try { ... |
String | encodeUri(URI uri) Encodes a URI into a flat character string. if (uri == null) { return ""; return uri.toASCIIString(); |
String | encodeURI(URI uri) encode URI return encodeURI(uri.toString());
|
String | encodeURIComponent(final String s) encode URI Component if (s == null || s.length() == 0) { return s; try { return URLEncoder.encode(s, "utf-8"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); |
String | encodeURIComponent(String component) encode URI Component String result; try { result = URLEncoder.encode(component, "UTF-8").replaceAll("%28", "(").replaceAll("%29", ")") .replaceAll("\\+", "%20").replaceAll("%27", "'").replaceAll("%21", "!").replaceAll("%7E", "~"); } catch (java.io.UnsupportedEncodingException e) { result = component; return result; ... |
String | encodeURIComponent(String input) encode URI Component try { return URLEncoder.encode(input, "UTF-8").replaceAll(" ", "%20").replaceAll("!", "%21") .replaceAll("'", "%27").replaceAll("\\(", "%28").replaceAll("\\)", "%29") .replaceAll("\\+", "%2B").replaceAll("\\:", "%3A").replaceAll("~", "%7E"); } catch (UnsupportedEncodingException e) { return null; |
String | encodeURIComponent(String s, String charset) Encodes the passed String as UTF-8 using an algorithm that's compatible with JavaScript's encodeURIComponent function.
if (s == null) { return null; } else { String result; try { result = URLEncoder.encode(s, charset).replaceAll("\\+", "%20").replaceAll("\\%21", "!") .replaceAll("\\%27", "'").replaceAll("\\%28", "(").replaceAll("\\%29", ")") .replaceAll("\\%7E", "~"); ... |
String | encodeURIComponent(String uriComp) encode URI Component try { return URLEncoder.encode(uriComp, "UTF-8").replaceAll("\\+", "%20"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Encoding URI component \"" + uriComp + "\" failed", e); |
String | encodeUriComponent(String value) encode Uri Component try { return convertToGAStyleEncoding(URLEncoder.encode(value, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); |
String | encodeURIComponentForJavaScript(String str) URI encodes a string for Javascript consumption; client should call decodeURIComponent to decode return URLEncoder.encode(str, "UTF-8").replaceAll("\\+", "%20").replaceAll("\\%21", "!") .replaceAll("\\%27", "'").replaceAll("\\%28", "(").replaceAll("\\%29", ")").replaceAll("\\%7E", "~") .replaceAll("\\%3B", ";"); |