Here you can find the source of urlEncode(String string)
public static String urlEncode(String string) throws UnsupportedEncodingException
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static final String UTF8_ENCODING = "UTF-8"; public static String urlEncode(String string) throws UnsupportedEncodingException { return URLEncoder.encode(string, UTF8_ENCODING).replace("+", "%20"); }/*from w w w. j ava2 s. com*/ }