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; import java.net.URLEncoder; public class Main { public static String toUTF8(String str) { try {// w w w . ja va 2 s.com return URLEncoder.encode(str, "UTF-8").replace("%2F", "/") .replace("+", " "); } catch (UnsupportedEncodingException ex) { return str; } } }