Java tutorial
//package com.java2s; import android.text.TextUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static String urlEncode(String msg) { if (TextUtils.isEmpty(msg)) { return null; } try { return URLEncoder.encode(msg, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }