Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.Charset; public class Main { public static final Charset charset = Charset.forName("utf-8"); public static final String urlEncode(String url) { try { return URLEncoder.encode(url, charset.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return url; } }