Java tutorial
//package com.java2s; public class Main { public static String trim(Object obj) { if (obj == null) { return ""; } return trim(obj.toString()); } public static String trim(String str) { if (str == null) { return ""; } try { str = java.net.URLDecoder.decode(str, "UTF-8"); } catch (Exception ex) { } return str.trim(); } }