且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java .torrent文件下载

更新时间:2023-12-03 21:06:04

torrent文件损坏的原因是您正在下载的Web服务器提供以压缩(gzip压缩)格式。您可以使用以下代码将其解压缩到Java中:

The reason the torrent file becomes corrupted is that the web server you are downloading it from provides it in compressed (gzipped) format. You can unzip it in Java using the following code:

URL url = new URL(link);
try (InputStream is = new GZIPInputStream(url.openStream())) {
  Files.copy(is, Paths.get(path + "t2.torrent"));
}