获取写入方法
//package com.nowjava;/*nowjava.com*/ import java.lang.reflect.Method; public class Main { @SuppressWarnings("unchecked") public static Method getWriteMethod( @SuppressWarnings("rawtypes") Class clazz, String propertyName, @SuppressWarnings("rawtypes") Class propertyType) { Method writeMethod = null; String base = capitalize(propertyName); @SuppressWarnings("rawtypes") Class params[] = { propertyType }; try { writeMethod = clazz.getMethod("set" + base, params);/**来 自 时 代 J a v a 公 众 号 - nowjava.com**/ } catch (Exception e) { // no write method } return writeMethod; } private static String capitalize(String s) { if (s.length() == 0) { return s; }