实战java反射机制-让你迅速认识java强大的反射机制
[url]http://stephen830.iteye.com/blog/256723[/url]
[url]http://topic.youkuaiyun.com/u/20100628/17/7729635b-a226-4bf5-aae1-c5e14924e575.html[/url]
好用
[url]http://stephen830.iteye.com/blog/256723[/url]
[url]http://topic.youkuaiyun.com/u/20100628/17/7729635b-a226-4bf5-aae1-c5e14924e575.html[/url]
public static Map<String, Object> dumpProperty2Map(Class obj) {
Map<String, Object> map = new Hashtable<String, Object>();
Field[] field1 = obj.getDeclaredFields();
for (int i = 0; i < field1.length; i++) {
field1[i].setAccessible(true);
try {
map.put(field1[i].getName(), field1[i].get(obj));
} catch (IllegalArgumentException e1) {
throw new STBSystemException(e1);
} catch (IllegalAccessException e2) {
throw new STBSystemException(e2);
}
}
return map;
}
好用