2015-09-03 31 views
-1

基本上我正在製作一個程序,它可以通過使用很多API來獲取電影中的所有信息。它還從電影下載一個.torrent文件。我想在我的程序中下載這個內容,並想使用tTorrent。唯一的問題是:我該如何使用它?在閱讀所有的安裝或自述文件,它並沒有爲我說什麼。我知道如何安裝一個普通的庫,但是這有多個地圖中的多個文件等。Java tTorrent庫:如何安裝和使用這些庫?

所以,第一個問題:你能否容易地解釋我如何一步一步安裝庫?

第二個問題:你還可以給我代碼如何使用它來下載一個.torrent文件?

順便說一句:如果有什麼方法可以自動打開與qBittorrent的.torrent文件,那麼這將是我唯一可以接受的選擇。

+4

在堆棧中的想法是你做一些努力卡住然後告訴大家你通過代碼做了什麼,並給出了錯誤信息,而不是簡單地要求別人提供幫助 –

回答

0

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.