Here you can find the source of encodeURIComponent(String component)
private static String encodeURIComponent(String component)
//package com.java2s; //License from project: Open Source License import java.net.URLEncoder; public class Main { private static String encodeURIComponent(String component) { String result;/* w ww . ja va2 s .c o m*/ 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; } }