springframework.beans.BeanUtils is very useful to copy objects, and I use the \"ignoreProperties\" option frequently. However, sometimes I want to copy only spe
Here is an Example with Spring BeanUtils class:
public static void copyList(List sourceList,
List targetList, Class targetType) {
try {
for (Object source : sourceList) {
Object target = null;
target = targetType.newInstance();
BeanUtils.copyProperties(source, target);
targetList.add(target);
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}