Here you can find the source of encode(String toBeEncoded, String charSet, String defaultReturnValue)
public static String encode(String toBeEncoded, String charSet, String defaultReturnValue)
//package com.java2s; //License from project: Apache License import java.net.URLEncoder; public class Main { public static String encode(String toBeEncoded, String charSet, String defaultReturnValue) { String encodedString;/* w ww .jav a 2s.c o m*/ try { encodedString = URLEncoder.encode(toBeEncoded, charSet); } catch (Exception var5) { System.err.println(String.format("Error when url-encode:%s with charset:%s", new Object[] { toBeEncoded == null ? "" : toBeEncoded, charSet == null ? "" : charSet })); var5.printStackTrace(); encodedString = defaultReturnValue; } return encodedString; } }