锘??xml version="1.0" encoding="utf-8" standalone="yes"?>丁香婷婷在线,欧美一区二区三区在线播放,你懂的免费在线观看视频网站http://www.aygfsteel.com/hector/鍗庡瓙璇達細鐪嬬牬綰㈠皹錛屼笌紼嬪簭涓轟即錛?/description>zh-cnTue, 17 Jun 2025 04:32:25 GMTTue, 17 Jun 2025 04:32:25 GMT60- 鍏充簬httpclient 璇鋒眰https 錛堝浣曠粫榪囪瘉涔﹂獙璇侊級http://www.aygfsteel.com/hector/archive/2012/10/23/390073.html璧但璧但Mon, 22 Oct 2012 23:26:00 GMThttp://www.aygfsteel.com/hector/archive/2012/10/23/390073.htmlhttp://www.aygfsteel.com/hector/comments/390073.htmlhttp://www.aygfsteel.com/hector/archive/2012/10/23/390073.html#Feedback1http://www.aygfsteel.com/hector/comments/commentRss/390073.htmlhttp://www.aygfsteel.com/hector/services/trackbacks/390073.htmlimport java.io.BufferedR... 闃呰鍏ㄦ枃

]]> - HttpClient 瀛︿範鏁寸悊銆愯漿銆?/title>http://www.aygfsteel.com/hector/archive/2012/10/23/390072.html璧但璧但Mon, 22 Oct 2012 23:20:00 GMThttp://www.aygfsteel.com/hector/archive/2012/10/23/390072.htmlhttp://www.aygfsteel.com/hector/comments/390072.htmlhttp://www.aygfsteel.com/hector/archive/2012/10/23/390072.html#Feedback0http://www.aygfsteel.com/hector/comments/commentRss/390072.htmlhttp://www.aygfsteel.com/hector/services/trackbacks/390072.html闃呰鍏ㄦ枃

]]> - Java澶氱嚎紼嬩笅杞芥枃浠?/title>http://www.aygfsteel.com/hector/archive/2012/10/23/390071.html璧但璧但Mon, 22 Oct 2012 22:52:00 GMThttp://www.aygfsteel.com/hector/archive/2012/10/23/390071.htmlhttp://www.aygfsteel.com/hector/comments/390071.htmlhttp://www.aygfsteel.com/hector/archive/2012/10/23/390071.html#Feedback0http://www.aygfsteel.com/hector/comments/commentRss/390071.htmlhttp://www.aygfsteel.com/hector/services/trackbacks/390071.html鏂囦歡涓嬭澆閲囩敤澶氱嚎紼嬫柟寮忚兘澶熷厖鍒嗗埄鐢–PU璧勬簮錛屽叧閿偣鏄緗嚎紼嬬殑璇誨彇寮濮嬪拰緇撴潫浣嶇疆銆備笅闈㈢殑浠g爜錛岄噰鐢ㄧ嚎紼嬫睜鍚姩10涓嚎紼嬫潵鎵ц涓嬭澆
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;



public class FileDownLoadTest
{
private static final int TCOUNT = 10;
private CountDownLatch latch = new CountDownLatch(TCOUNT);

private long completeLength = 0;
private long fileLength;

/** *//**
* @param args
* @throws Exception
*/

public static void main(String[] args) throws Exception
{
new FileDownLoadTest().download("http://localhost:8080/test/IESSAction.docx");
}

public void download(String address) throws Exception
{
ExecutorService service = Executors.newFixedThreadPool(TCOUNT);
URL url = new URL(address);
URLConnection cn = url.openConnection();
cn.setRequestProperty("Referer", "http://www.test.com");
fileLength = cn.getContentLength();
long packageLength = fileLength/TCOUNT;
long leftLength = fileLength%TCOUNT;
RandomAccessFile file = new RandomAccessFile("d:\\test.docx","rw");
//璁$畻姣忎釜綰跨▼璇鋒眰鏂囦歡鐨勫紑濮嬪拰緇撴潫浣嶇疆
long pos = 0;
long endPos = pos + packageLength;

for(int i=0; i<TCOUNT; i++)
{

if(leftLength >0)
{
endPos ++;
leftLength--;
}
service.execute(new DownLoadThread(url, file, pos, endPos));
pos = endPos;
endPos = pos + packageLength;
}
System.out.println("waiting











.");
long begin = System.currentTimeMillis();
latch.await();
file.close();
System.out.println("end











.");
System.out.println(System.currentTimeMillis() - begin + "ms");
service.shutdown();
}

class DownLoadThread implements Runnable
{
private URL url;
private RandomAccessFile file;
private long from;
private long end;

DownLoadThread(URL url, RandomAccessFile file, long from, long end)
{
this.url = url;
this.file = file;
this.from = from;
this.end = end;
}

public void run()
{
long pos = from;
byte[] buf = new byte[512];

try
{
HttpURLConnection cn = (HttpURLConnection) url.openConnection();
cn.setRequestProperty("Range", "bytes=" + from + "-" + end);

if(cn.getResponseCode() != 200 && cn.getResponseCode()!=206)
{
run();
return;
}
BufferedInputStream bis = new BufferedInputStream(cn.getInputStream());
int len ;

while((len = bis.read(buf)) != -1)
{
// synchronized(file){
file.seek(pos);
file.write(buf, 0, len);
// }
pos += len;
completeLength +=len;
System.out.println("threadName: " + Thread.currentThread().getName()
+ "persent: " + completeLength * 100 /fileLength + "%");
}
cn.disconnect();
latch.countDown();

} catch (IOException e)
{
e.printStackTrace();
}
}
}
}

]]> - Ext js瀵煎嚭Excelhttp://www.aygfsteel.com/hector/archive/2012/10/22/390016.html璧但璧但Mon, 22 Oct 2012 08:15:00 GMThttp://www.aygfsteel.com/hector/archive/2012/10/22/390016.htmlhttp://www.aygfsteel.com/hector/comments/390016.htmlhttp://www.aygfsteel.com/hector/archive/2012/10/22/390016.html#Feedback0http://www.aygfsteel.com/hector/comments/commentRss/390016.htmlhttp://www.aygfsteel.com/hector/services/trackbacks/390016.html闃呰鍏ㄦ枃

]]>
主站蜘蛛池模板:
沙坪坝区|
慈利县|
娄底市|
芮城县|
张北县|
黄龙县|
商城县|
且末县|
舞阳县|
临江市|
修武县|
瑞丽市|
苍溪县|
宕昌县|
拜泉县|
金山区|
达拉特旗|
苍梧县|
扶绥县|
紫金县|
老河口市|
德兴市|
托克托县|
大城县|
海晏县|
云浮市|
桦南县|
托克逊县|
曲靖市|
桂阳县|
集安市|
香格里拉县|
长阳|
普安县|
邮箱|
乐平市|
呈贡县|
朝阳区|
怀仁县|
巴林左旗|
通渭县|