• java 解析/读取 种子/bt/torrent 内容


    碰到不会的技术问题,我还是先度娘。能中文看懂,为什么非要看英文呢。

    java 解析/读取 种子/bt/torrent  内容,这个度娘给的满意答案并不是很多。GG之后的搜索结果出现了stackoverflow这个网站,技术人员都懂的,基本有解决方案了,犹如黑暗里的萤火虫,早期度娘java问题的javaeye。

    有3种解决方案

    1、不适用第三方jar,可以看看 http://blog.csdn.net/phinecos/article/details/4611924。 度娘给的基本都是这种解决方案。顺便鄙视下国内的某些程序员,转载别人的文章时,也不测试下,结果1传10,10传100,都是有bug的。

    2、使用jbittorrent api,说实话,没研究怎么玩。由于本人已离开了这个行业,适用为主。

    3、Eclipse ecf,第一次听说,不懂的同学自己度娘或GG。实际上是一个插件,进入eclipse官网,下载压缩包,比较大(16.1M),因为我们要的只是解析BT,只需要其中的一个jar文件即可。打开压缩包,在 plugins 目录下,找到以下文件

     我们只需要第二个即可,也不大,74K。

    这是在线API地址:http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/protocol/bittorrent/TorrentFile.html

    接下来就纯Demo

     1 import org.eclipse.ecf.protocol.bittorrent.TorrentFile;
     2 
     3 public class Test
     4 {
     5     public static void main(String[] args) throws Exception
     6     {
     7         String path = "d:/0623060253062306025306.torrent";
     8         
     9         TorrentFile file = new TorrentFile(new File(path));
    10         
    11         String[] strs = file.getFilenames();
    12         long[] longs = file.getLengths();
    13         System.out.println(strs.length + " " + longs.length);
    14         
    15         for(int i = 0; i < strs.length; i ++)
    16         {
    17             System.err.println(strs[i] + " --->  " + longs[i]);
    18         }
    19         
    20         
    21     }
    22 }

    显示结果,大家自己加table或者div就OK。

    如下是迅雷解析BT,我们现在也能实现如下效果了。

  • 相关阅读:
    C++11 并发指南四(<future> 详解三 std::future & std::shared_future)(转)
    转: 关于 ssl的建立链接的过程
    工信部电信投诉网站入口
    rfc 标准文档目录
    转: 七牛云的开源播放器的使用指南
    转: Android基于HLS和RTMP协议的第三方SDK选择
    转:Android中Context详解 ---- 你所不知道的Context
    android开发推荐书籍列表
    转:java 类名 this 的使用
    转: android studio 消除SDK更新时的“https://dl-ssl.google.com refused”错误
  • 原文地址:https://www.cnblogs.com/heyus/p/3183868.html
Copyright © 2020-2023  润新知