Here you can find the source of encodeToUTF8(String str)
public static String encodeToUTF8(String str) throws UnsupportedEncodingException
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; public class Main { public static String encodeToUTF8(String str) throws UnsupportedEncodingException { return encode(str, StandardCharsets.UTF_8.name()); }/* w w w .j a va2s . c o m*/ public static String encode(String str, String charsetName) throws UnsupportedEncodingException { return new String(str.getBytes(), charsetName); } }