锘??xml version="1.0" encoding="utf-8" standalone="yes"?>91亚洲人成网污www,色香蕉成人二区免费,久久国产精品99国产精http://www.aygfsteel.com/hector/鍗庡瓙璇達(dá)細(xì)鐪嬬牬綰㈠皹錛屼笌紼嬪簭涓轟即錛?/description>zh-cnTue, 17 Jun 2025 09:31:37 GMTTue, 17 Jun 2025 09:31:37 GMT60- 鍏充簬httpclient 璇鋒眰https 錛堝浣曠粫榪囪瘉涔﹂獙璇侊級(jí)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 瀛︿範(fàn)鏁寸悊銆愯漿銆?/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闃呰鍏ㄦ枃

]]>
主站蜘蛛池模板:
鱼台县|
渝中区|
眉山市|
浙江省|
井冈山市|
东港市|
旅游|
贵溪市|
宜昌市|
新田县|
合川市|
广河县|
鹿泉市|
平定县|
依安县|
上虞市|
尤溪县|
潍坊市|
沭阳县|
台南县|
天气|
西城区|
杂多县|
三台县|
东阿县|
六安市|
镇宁|
蒙阴县|
平泉县|
望谟县|
青岛市|
桂东县|
西乡县|
建昌县|
灌阳县|
遵义县|
徐水县|
东阿县|
南昌县|
云浮市|
申扎县|