public static void pojoToString(Object obj) {
Class<?> cls = obj.getClass();
Field fieldlist[] = cls.getDeclaredFields();
for (int i = 0; i < fieldlist.length; i++) {
Field fld = fieldlist[i];
// Util.i("name = " + fld.getName());
// Util.i("decl class = " + fld.getDeclaringClass());
// Util.i("type = " + fld.getType());
// int mod = fld.getModifiers();
// Util.i("modifiers = " + Modifier.toString(mod));
try {
Util.i(fld.getName() + "=" + fld.get(obj));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
댓글