gpt4 book ai didi

java - 比特流客户端 : ttorrent doesn't work

转载 作者:行者123 更新时间:2023-11-30 03:20:52 26 4
gpt4 key购买 nike

我想使用 ("/sdcard/file.torrent") 上保存的 .torrent 文件开始简单下载。
我试过ttorrent,因为它是最简单的比特流客户端。
ttorrent on github.com所以我试过这段代码,但有错误...

String filePath = "/sdcard/file.torrent";
String downPath = "/sdcard/A";

Client client = new Client (
InetAddress.getLocalHost(),
SharedTorrent.fromFile(
new File(filePath),
new File(downPath)
)
);

client.setMaxDownloadRate(0.0);
client.setMaxUploadRate(0.0);
client.download();
client.share(0);
client.waitForCompletion();

日志:

E/AndroidRuntime(5992): FATAL EXCEPTION: main
E/AndroidRuntime(5992): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHex
E/AndroidRuntime(5992): at com.turn.ttorrent.common.Torrent.byteArrayToHexString(Torrent.java:415)
E/AndroidRuntime(5992): at com.turn.ttorrent.common.Torrent.<init>(Torrent.java:145)
E/AndroidRuntime(5992): at com.turn.ttorrent.client.SharedTorrent.<init>(SharedTorrent.java:175)
E/AndroidRuntime(5992): at com.turn.ttorrent.client.SharedTorrent.<init>(SharedTorrent.java:159)
E/AndroidRuntime(5992): at com.turn.ttorrent.client.SharedTorrent.fromFile(SharedTorrent.java:239)
E/AndroidRuntime(5992): at com.torrentsearch.activities.ResultList.onContextItemSelected(ResultList.java:435)
E/AndroidRuntime(5992): at android.app.Activity.onMenuItemSelected(Activity.java:2647)
E/AndroidRuntime(5992): at com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3921)
E/AndroidRuntime(5992): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
E/AndroidRuntime(5992): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
E/AndroidRuntime(5992): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
E/AndroidRuntime(5992): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:193)
E/AndroidRuntime(5992): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:934)
E/AndroidRuntime(5992): at android.widget.AdapterView.performItemClick(AdapterView.java:301)
E/AndroidRuntime(5992): at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
E/AndroidRuntime(5992): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3071)
E/AndroidRuntime(5992): at android.widget.AbsListView$1.run(AbsListView.java:3973)
E/AndroidRuntime(5992): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(5992): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(5992): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(5992): at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(5992): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5992): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
E/AndroidRuntime(5992): at dalvik.system.NativeStart.main(Native Method)

最佳答案

问题出在 apache-commons 库中。我使用的是 1.8(最新版本),但对于这个 ttorrent 客户端 1.2 version是需要的。

client.setMaxDownloadRate(0.0);
0.0 不限制下载速度。但下载速度太慢,Android uTorrent 有更多。

关于java - 比特流客户端 : ttorrent doesn't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19161063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com