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