码迷,mamicode.com
首页 > 其他好文 > 详细

转化对象为map方法

时间:2014-07-29 21:05:22      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   os   io   for   代码   

言语不多,直接上代码。

private  Map<String, Object> introspect(Object obj) throws Exception {
        Map<String, Object> result = new HashMap<String, Object>();
        BeanInfo info = Introspector.getBeanInfo(obj.getClass());
        for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
            Method reader = pd.getReadMethod();
            if (reader != null)
                result.put(pd.getName(), reader.invoke(obj));
        }
        return result;
    }

 

转化对象为map方法,布布扣,bubuko.com

转化对象为map方法

标签:des   style   blog   color   os   io   for   代码   

原文地址:http://www.cnblogs.com/a393060727/p/3876114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!