日期:2014-05-20 浏览次数:20925 次
public static InputStream skipFully(InputStream in,long howMany)throws Exception{
long remainning = howMany;
long len = 0;
while(remainning>0){
len = in.skip(len);
remainning -= len;
}
return in;
}
------解决方案--------------------
Thread dl = new Thread(){
public void run(){
try{
String n = jtf.getText();
int s = n.lastIndexOf("/");
String tar = n.substring((s+1));
URL url = new URL(jtf.getText());
URLConnection uc = url.openConnection();
long total = uc.getContentLength();
InputStream is = uc.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is,1024*1024*10);
FileOutputStream fos = new FileOutputStream(tar,true);
BufferedOutputStream bos = new BufferedOutputStream(fos,1024*1024*10);
File tarFile = new File(tar);
long count = tarFile.length();
is.skip(count);
byte[] data = new byte[1024*1024*10];
int (Stri