package com.dw.downloader;

import java.io.IOException;
import java.net.*;

public class TestDownloader {
	public static void main(String[] args) {
	    int len = 0;
	    String path = "http://dl1.video.varzesh3.com/video/clip93/12/video/havashi/top5_save_derby_dortmond.mp4";
	    URL url;
		try {
			url = new URL(path);
		
		    URLConnection connectUrl = url.openConnection();
		    System.out.println(len = connectUrl.getContentLength());
		    System.out.println(connectUrl.getContentType());
	    
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		catch (IOException e){
			e.printStackTrace();
		}
	}
}

@@ -36,27 +36,138 @@
 java.io.
-IOException
+File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream
 ;%0Aimport
@@ -485,16 +485,78 @@
 tion();%0A
+%09%09    connectUrl.setRequestProperty(%22Range%22, %22Bytes=0-1024%22);%0A
 %09%09    Sy
@@ -610,16 +610,16 @@
 gth());%0A
-
 %09%09    Sy
@@ -665,16 +665,513 @@
 ype());%0A
+%09%09    connectUrl.connect();%0A%09%09    File file = new File(%22/Users/ewu/test/test.mp4%22);%0A%09%09    %0A%09%09    OutputStream outputStream = null;%0A%09%09    outputStream = new FileOutputStream(new File(%22/Users/ewu/test/test.mp4%22));%0A%09%09    %0A%09%09    InputStream inputStream = connectUrl.getInputStream();%0A%09%09    int read = 0;%0A%09%09%09byte%5B%5D bytes = new byte%5B1024%5D;%0A%09%09    while ((read = inputStream.read(bytes)) != -1) %7B%0A%09%09%09%09outputStream.write(bytes, 0, read);%0A%09%09%09%7D%0A%09%09    %0A%09%09    outputStream.flush();%0A%09%09    outputStream.close();%0A
 %09    %0A%09%09

add file header range for dowloading.