Here you can find the source of encodeStringUtf8(String text)
public static String encodeStringUtf8(String text)
//package com.java2s; //License from project: Open Source License import java.nio.charset.Charset; public class Main { public static String encodeStringUtf8(String text) { return new String(Charset.forName("UTF-8").encode(text).array()); }// w ww . jav a2s.co m }