Here you can find the source of encode(String value, String charset)
public static String encode(String value, String charset)
//package com.java2s; //License from project: Apache License import java.io.*; import java.net.URLEncoder; public class Main { public static final String DEFAULT_CHARSET = "UTF-8"; public static String encode(String value) { return encode(value, DEFAULT_CHARSET); }/*from www . j a va 2 s. co m*/ public static String encode(String value, String charset) { String result = null; if (!isEmpty(value)) { try { result = URLEncoder.encode(value, charset); } catch (IOException e) { throw new RuntimeException(e); } } return result; } private static boolean isEmpty(final String str) { return str == null || str.length() == 0; } }