Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /** * Returns encoded String * * @param sUrl * , input string * @return , encoded string */ public static String urlEncode(String sUrl) { try { return URLEncoder.encode(sUrl, "UTF-8").replace("+", "%20"); } catch (UnsupportedEncodingException e) { return null; } } }