java - tTorrent 客户端错误

标签 java file bittorrent

我正在尝试在我的程序中实现 tTorrent 客户端,我查看了此链接的示例 ( https://github.com/mpetazzoni/ttorrent/issues/16 ) 并将该代码放入我的程序的 Download 类中。这是代码:

导入语句:

import main.java.com.turn.ttorrent.client.Client;
import main.java.com.turn.ttorrent.client.SharedTorrent;
import main.java.com.turn.ttorrent.common.Torrent;
import main.java.com.turn.ttorrent.tracker.TrackedTorrent;
import main.java.com.turn.ttorrent.tracker.Tracker; 



// Create tracker instance
    Tracker tracker = new Tracker(InetAddress.getLocalHost());
    // Load torrent file
    File torrentFile = new File("/path/to/torrentFile.torrent");
    // Create torrent instance
    TrackedTorrent torrent = new TrackedTorrent(Torrent.load(torrentFile, null));
    // Announce torrent
    tracker.announce(torrent);
    // Start the tracker
    tracker.start();

    torrentFile = new File(path + ".torrent");
    File downloadDir = new File("/path/to/torrents_download_dir");//unsure

    Client client = new Client(InetAddress.getLocalHost(), SharedTorrent.fromFile(torrentFile, downloadDir));
    // Add client.share(); if you wish to share the torrent infinitely
    client.run();

当我将鼠标悬停在负载上时,收到此错误消息:

The method load(File, boolean) in the type Torrent is not applicable for the arguments (File, null)

我也不确定应该在 File downloadDir 中放置什么。我仍然是一个初学者,如果有人能指出我正确的方向,将其放入我的程序中,那就太好了。我还是个初学者。

最佳答案

Torrent.load(torrentFile, null) 想要一个 File 对象。

例如

Torrent.load(new File(/foo/path.torrent), null)

关于java - tTorrent 客户端错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22132964/

相关文章:

windows - 如何在 ruby​​ 中设置 Windows 相关的文件属性?

python - 如何从 UDP 跟踪器通告响应中解析对等方的 IP 和端口

java - 在 EclipseLink 中以编程方式创建 <class> 定义

file - java我: How to clear a file

java - 访问请求范围的 bean

javascript - 关于使用 Dropbox API 和 Javascript 访问文件的帮助

java - 如何使用 Java 计算 torrent 的哈希值

bittorrent - 对等点如何知道另一个对等点是种子?

java - 如何在我的 Vaadin 服务中接收文件内容?

Ubuntu Linux 上的 Java SE 6 : How to open files externally by Runtime. getRuntime().exec()?