Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30465483
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: Java

2008-06-23 14:05:11

public String toString() {
        try {
            Map map = BeanUtils.describe(this);
            Iterator keyIt = map.keySet().iterator();
            StringBuffer aBuffer = new StringBuffer();

            while (keyIt.hasNext()) {
                String key = (String) keyIt.next();

                if ("class".equals(key)) {
                    continue;
                }

                String value = (String) map.get(key);

                if (aBuffer.length() > 0) {
                    aBuffer.append(", ");
                }

                aBuffer.append(key + " = [" + value + "]");
            }

            return aBuffer.toString();
        } catch (Exception e) {
            return super.toString();
        }
    }

阅读(838) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~