Here you can find the source of toUTF8(String s, String encoding)
public static String toUTF8(String s, String encoding) throws Exception
//package com.java2s; //License from project: Open Source License public class Main { public static String toUTF8(String s, String encoding) throws Exception { if (s != null && s.length() > 0) { byte[] byteTmp = s.getBytes(encoding); s = new String(byteTmp, "UTF-8"); }/*from w ww .j a va2s . com*/ return s; } }