Here you can find the source of encodeThoroughly(String s)
public static String encodeThoroughly(String s)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { private static final String defaultFormat = "utf-8"; public static String encodeThoroughly(String s) { String result;/*from w w w .j a v a2s.c o m*/ try { result = URLEncoder.encode(s, "UTF-8").replaceAll("\\+", "%20").replaceAll("\\%21", "!") .replaceAll("\\%27", "'").replaceAll("\\%28", "(").replaceAll("\\%29", ")") .replaceAll("\\%7E", "~"); } catch (UnsupportedEncodingException e) { result = s; } return result; } public static String encode(String input) { String encodedInput = ""; try { encodedInput = URLEncoder.encode(input, defaultFormat); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } assert (encodedInput.length() > 0); return encodedInput; } }