public static Object getFieldValue(Object obj, String name) {
        Class<?> clazz = obj.getClass();
        try {
            Field f = clazz.getDeclaredField(name);
            return f.get(obj);
        }
        catch (Exception e) {
            return null;
        }
    }
public static Object getFieldValue ( Object obj , String name ) { Class < ? > clazz = obj . getClass ( ) ; try { Field f = clazz . getDeclaredField ( name ) ; return f . get ( obj ) ; } catch ( Exception e ) { return null ; } }
Get the value of a declared field on an object

@param obj
@param name
@return The object value or null if there is no such field or access problems