Here you can find the source of decodeStringFields(Object objBean, String code)
public static void decodeStringFields(Object objBean, String code)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.URLDecoder; public class Main { public static void decodeStringFields(Object objBean, String code) { if (objBean == null) { return; }/*from w ww.j a va 2 s . c o m*/ Field[] fields = objBean.getClass().getDeclaredFields(); String value = null; Object objValue = null; for (Field field : fields) { if (field.getType() == String.class) { try { if (!Modifier.isPublic(field.getModifiers())) { field.setAccessible(true); } objValue = field.get(objBean); if (objValue != null) { value = objValue.toString(); field.set(objBean, URLDecoder.decode(value, code)); } } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } } } } }