Here you can find the source of encode(String s)
public static String encode(String s)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**//from w w w . ja v a2 s . co m * URL encodes the specified string using the UTF-8 character encoding. */ public static String encode(String s) { try { return (s != null) ? URLEncoder.encode(s, "UTF-8") : null; } catch (UnsupportedEncodingException uee) { throw new RuntimeException("UTF-8 is unknown in this Java."); } } }