Here you can find the source of toUtf8String(String source)
public static String toUtf8String(String source) throws UnsupportedEncodingException
//package com.java2s; /*/* ww w .jav a2 s.c om*/ * BJAF - Beetle J2EE Application Framework * ???J2EE??????????? * ??????2003-2015 ??? (www.beetlesoft.net) * * ?????????????????? *<http://www.apache.org/licenses/LICENSE-2.0> *???????????????????????? * * ??????????????????????????????? * ??? <yuhaodong@gmail.com/>. */ import java.io.UnsupportedEncodingException; public class Main { public static String toUtf8String(String source) throws UnsupportedEncodingException { if (source == null) { return null; } if (source.equals(new String(source.getBytes("ISO-8859-1"), "ISO-8859-1"))) { return new String(source.getBytes("ISO-8859-1"), "UTF-8"); } return source; } }