How to resume broken download in Java code
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Laxman_Subramanian
Posted On:   Thursday, September 19, 2002 02:48 PM

I tried using the URL connection to download content from a website . I would like to know how to resume broken download instead of starting from the scratch .

Re: How to resume broken download in Java code

Posted By:   Lasse_Koskela  
Posted On:   Thursday, September 19, 2002 03:14 PM

The basic idea is that during the download, you frequently store the downloaded bytes into the disk (harddisk that is) and save the number of bytes downloaded successfully.


Then, upon resuming the download, you continue by downloading the next not-yet-downloaded byte and so on, appending the new stuff to the old stuff.


So, that was the basic idea. The implementation is another thing.


If you have access to the server-side stuff you could add a front for the downloadable content, say, a servlet taking two parameters: resource identifier, and the last downloaded byte (0 if a completely new download). Then, the servlet could read the resource locally at server-side and start writing to the network socket after X bytes have been looped from the beginning.


I don't know if this is really a viable solution, but that's the first thing that came in mind.

About | Sitemap | Contact