1) maven をインストールし、maven を使用して簡単な「Hello World」プロジェクトを開始する方法を調べます。それを把握したら、追加します
<dependency>
<groupId>com.turn</groupId>
<artifactId>ttorrent</artifactId>
<version>1.4</version>
</dependency>
pom.xml に
2) リンクしたページから:
// First, instantiate the Client object.
Client client = new Client(
// This is the interface the client will listen on (you might need something
// else than localhost here).
InetAddress.getLocalHost(),
// Load the torrent from the torrent file and use the given
// output directory. Partials downloads are automatically recovered.
SharedTorrent.fromFile(
new File("/path/to/your.torrent"),
new File("/path/to/output/directory")));
// You can optionally set download/upload rate limits
// in kB/second. Setting a limit to 0.0 disables rate
// limits.
client.setMaxDownloadRate(50.0);
client.setMaxUploadRate(50.0);
// At this point, can you either call download() to download the torrent and
// stop immediately after...
client.download();
// Or call client.share(...) with a seed time in seconds:
// client.share(3600);
// Which would seed the torrent for an hour after the download is complete.
// Downloading and seeding is done in background threads.
// To wait for this process to finish, call:
client.waitForCompletion();
// At any time you can call client.stop() to interrupt the download.