Here you can find the source of setFieldValue(Object obj, String propertyName, Object value)
public static void setFieldValue(Object obj, String propertyName, Object value)
//package com.java2s; import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object obj, String propertyName, Object value) {/* w w w. j ava2 s . com*/ try { Field field = obj.getClass().getDeclaredField(propertyName); field.setAccessible(true); field.set(obj, value); } catch (Exception ex) { throw new RuntimeException(); } } }