【JAVA】从0开始写DHT磁力爬虫 02 Bencode实现

实现Bencode借用github上开源项目 做了一些改造 https:githubdampcakebencode新增方法encode(object o)实际上是利用反射将复杂对象转为map public static

实现Bencode借用github上开源项目 做了一些改造

https://github/dampcake/bencode

 新增方法encode(object o) 

实际上是利用反射将复杂对象转为map

    public static Map<String, Object> beanToMapComplate(Object bean) {
        if (bean == null) {
            return null;
        }
        Map<String, Object> map = new TreeMap<String, Object>();
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            for (PropertyDescriptor property : propertyDescriptors) {
                String key = property.getName();
                if (!key.equals("class")) {
                    Method gette

发布者:admin,转转请注明出处:http://www.yc00.com/web/1740360645a4234095.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信