Here you can find the source of toUtf8(String str)
public static String toUtf8(String str)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; public class Main { public static String toUtf8(String str) { String val = ""; try {/*from w w w. j a v a 2s . c o m*/ val = new String(str.getBytes("UTF-8"), "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return val; } }