????????????????????????????apache??????y?????????????????????α????HTTP Pseudo-Streaming??????????????????????ɡ?

??????????????????????HTTP????????????????????檔??????????????Щ????????y??????????????

??????????????????????????????????????????????????

???????????????????????????????????

??????????????????????????????????????????ж???????????

???????????????????3???????

????1?????????????????

????2???????????????????棨?????????????????????????????????????????

????3??????????????????????????????????????

??????????????????????????????????м??????????????С???????????????

??????????????????????????????????????????????y????????????????????????????????????????????????????????????CPU???????????

???????????????Ч??????????????£????????????????·???????????????????????????????????????IO????????????????н????????????ж??????Ч?????????????????????????????????????????????????????????????????????????????????????????????????Ч???????????????????????????????????????

????????????????????????????

????????????FMS????y?壬?????????????????????????????????????????

??????HTTP??????????????????????У??????????????

??????????Ч??????????????????鷳???

?????????·??JAVA?????????????LR??JAVA Vuser?????????????

????????????????????????????

?????
???????√
?????б?√
??????????????????????????√
*α????????????????
*?????????

????????
apache????
???????
???????

???????
jar??????exe??????Σ??????б??

?????????????????????????????δ????????????????????????

??????????????????????????????????????????????????????apache?????????????????????????????

?????????????и????????????????????apache??????????п???????????????????????????????????“α????????”??

????????????????????????????????

?????????????????????

package com.test;
 import java.io.*;
 import java.net.*;
 import java.util.*;
 
 public class DownloadFile {
 
     /*
      *???????URL?????
      *userid????????汾?????????
      **/
     public static int getHttpFileByUrl(String address?? String userid) {
         int bufferSize = 1024;
         int size = 0;
         byte[] buf = new byte[bufferSize];
       
         /*
          *????????????
          *??????????
          *???201210260130
          **/      
         Date date = new Date();23         SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
         String downloadTime = formatDate.format(date);
       
          /*
           *??????????????
           */
         int totalDownloadSize = 0;
         int lastDownloadSize = 0;
         long lastCheckTime = 0;
         long startDownloadTime = 0;
         int sec = 0;
       
         /*
          *???????????
          */
         try {
             URL url = new URL(address);
             URLConnection conn = url.openConnection();
             BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
             FileOutputStream fos = new FileOutputStream("e: est estvideo" + "_" + downloadTime + "_" + userid);
           
             System.out.println("File Size??" + conn.getContentLength()/1024 + "KB");
           
             startDownloadTime = System.currentTimeMillis();
             lastCheckTime = startDownloadTime;
           
             while ((size = bis.read(buf)) != -1)
             {
                 fos.write(buf??0??size);
                 totalDownloadSize += size;
               
                 /*
                  *??????????????
                  */
                 if (System.currentTimeMillis() - lastCheckTime > 1000) {
                     System.out.println(sec + ": " + (totalDownloadSize - lastDownloadSize)/1024 + "KB");
                     lastCheckTime = System.currentTimeMillis();
                     lastDownloadSize = totalDownloadSize;
                     sec++;
                 }
             }
           
             System.out.println("Vuser " + userid + " Download Completed!");
             System.out.println("Average Download Speed: " + (totalDownloadSize/1024)/((System.currentTimeMillis() - startDownloadTime)/1000) + "KB/s");
           
             fos.close();
             bis.close();
           
         }catch (MalformedURLException e) {
             e.printStackTrace();
         }catch (IOException e) {
             e.printStackTrace();
         }
       
         return totalDownloadSize/1024;
     }  
 }

??????????????

import com.test.*;
 import java.util.*;
 import java.io.*;
 
 public class DownloadDrive {
 
     public static void main (String[] args) {
       
         //System.out.println("test");
         //DownloadFile.test();
       
         /*
          *?????????
          *???????
          */
         int DownLoadSize = 0;
         double DownLoadTime = 0;
         int Speed = 0;
               
         String url;
         ArrayList urlList = new ArrayList();
 
         /*
          *??????????URL???
          *???浽list??
          */
         try{
             BufferedReader br = new BufferedReader(new FileReader("url.txt"));
             while((url = br.readLine()) != null){
                 urlList.add(url);
             }  
         }catch(IOException ie){
             ie.printStackTrace();
         }
       
         System.out.println("Total URLs: " + urlList.size());
       
         /*
          *????????list?е????
          */
         for(int i = 0; i < urlList.size(); i++){
             url = (String)urlList.get(i);
             System.out.println(url);          
             //????url??????????????
             DownloadFile.getHttpFileByUrl(url?? "1");
         }
     }  
   
 }

?????????????URL???浽url.txt?У??????????????????DownloadDrive.class????С?