package test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String urlStr = "http://zoink.it/torrent/702A285016D389DAB42CA857DBB840742FCB5B5F.torrent" ;
File file = new File("D:\\702A285016D389DAB42CA857DBB840742FCB5B5F") ;
FileOutputStream fos;
try {
URL url = new URL(urlStr);
HttpURLConnection urlConn = (HttpURLConnection) url
.openConnection();
InputStream is = urlConn.getInputStream();
fos = new FileOutputStream(file);
byte[] buffer = new byte[512] ;
int len = 0 ;
while((len = is.read(buffer)) != -1){
fos.write(buffer,0,len) ;
}
is.close() ;
fos.flush() ;
fos.close() ;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这是我写的一段代码,
在浏览器敲下面的地址可以下载下来有效的种子文件
http://zoink.it/torrent/702A285016D389DAB42CA857DBB840742FCB5B5F.torrent
但通过java程序下载下来的种子就是失效的,貌似种子大小还不一样。
对这方面了解的可以指导一下。
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String urlStr = "http://zoink.it/torrent/702A285016D389DAB42CA857DBB840742FCB5B5F.torrent" ;
File file = new File("D:\\702A285016D389DAB42CA857DBB840742FCB5B5F") ;
FileOutputStream fos;
try {
URL url = new URL(urlStr);
HttpURLConnection urlConn = (HttpURLConnection) url
.openConnection();
InputStream is = urlConn.getInputStream();
fos = new FileOutputStream(file);
byte[] buffer = new byte[512] ;
int len = 0 ;
while((len = is.read(buffer)) != -1){
fos.write(buffer,0,len) ;
}
is.close() ;
fos.flush() ;
fos.close() ;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这是我写的一段代码,
在浏览器敲下面的地址可以下载下来有效的种子文件
http://zoink.it/torrent/702A285016D389DAB42CA857DBB840742FCB5B5F.torrent
但通过java程序下载下来的种子就是失效的,貌似种子大小还不一样。
对这方面了解的可以指导一下。