最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

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

业界 admin 0浏览 0评论

实现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

实现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
发布评论

评论列表 (0)

  1. 暂无评论