Here you can find the source of encode(final String content, final String encoding)
private static String encode(final String content, final String encoding)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { private static String encode(final String content, final String encoding) { try {// ww w . j av a 2 s . c o m return URLEncoder.encode(content, encoding != null ? encoding : "UTF-8"); } catch (UnsupportedEncodingException problem) { throw new IllegalArgumentException(problem); } } }