Here you can find the source of encode(String text, String encoding)
public static String encode(String text, String encoding) throws UnsupportedEncodingException
//package com.java2s; //License from project: LGPL import java.io.UnsupportedEncodingException; import javax.mail.internet.MimeUtility; public class Main { public static String encode(String text, String encoding) throws UnsupportedEncodingException { //print.ln(StringUtil.changeCharset(text,encoding)); return MimeUtility.encodeText(text, encoding, "Q"); }//from www . ja v a 2 s . co m }