Here you can find the source of encodeURIComponent(final String s)
public static final String encodeURIComponent(final String s)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static final String encodeURIComponent(final String s) { if (s == null || s.length() == 0) { return s; }//w ww.ja v a 2 s .c om try { return URLEncoder.encode(s, "utf-8");// StrFunc.UTF8 } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }