Here you can find the source of encodeUTF8(String s)
public static String encodeUTF8(String s)
//package com.java2s; import java.net.URLEncoder; public class Main { public static String encodeUTF8(String s) { try {/*w w w .java 2s. co m*/ if (s == null || s.equals("")) return ""; s = URLEncoder.encode(s, "UTF-8"); s = s.replaceAll("\\+", "%20"); return s; } catch (Exception e) { e.printStackTrace(); return s; } } }