Java tutorial
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static String encodeStr(String s) { String s1; try { s1 = URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException unsupportedencodingexception) { unsupportedencodingexception.printStackTrace(); return null; } catch (Exception exception) { exception.printStackTrace(); return null; } return s1; } }