Java tutorial
//package com.java2s; import java.net.URLEncoder; public class Main { public static String toURLEncoded(String paramString) { if (paramString == null || paramString.equals("")) { return ""; } try { String str = new String(paramString.getBytes(), "UTF-8"); str = URLEncoder.encode(str, "UTF-8"); return str; } catch (Exception localException) { // Log.i("--","toURLEncoded error:"+paramString, localException); } return ""; } }