复制
public static boolean copy(Object source, Object to) { try { BeanInfo sourceBean = Introspector.getBeanInfo(source.getClass(),java.lang.Object.class); PropertyDescriptor[] sourceProperty = sourceBean.getPropertyDescriptors(); BeanInfo destBean = Introspector.getBeanInfo(to.getClass(),java.lang.Object.class); PropertyDescriptor[] destProperty = destBean.getPropertyDescriptors(); for (int i = 0; i < sourceProperty.length; i++) { for (int j = 0; j < destProperty.length; j++) { if (sourceProperty[i].getName().equals(destProperty[j].getName())) { destProperty[j].getWriteMethod().invoke(to,sourceProperty[i].getReadMethod().invoke(source)); break; } } } return true; } catch (Exception e) { e.printStackTrace(); return false; } }