public void SetValue(Object obj, String fieldName, Object value)
			throws SecurityException, NoSuchFieldException,
			NoSuchMethodException, IllegalArgumentException,
			IllegalAccessException, InvocationTargetException {
		String firstLetter = fieldName.substring(0, 1).toUpperCase();
		String setMethodName = "set" + firstLetter + fieldName.substring(1);
		Field field = obj.getClass().getDeclaredField(fieldName);
		Method setMethod = obj.getClass().getDeclaredMethod(setMethodName,
				field.getType());
		setMethod.invoke(obj, value);
	}
posted on 2011-10-16 21:46 
aya000 阅读(1336) 
评论(0)  编辑  收藏