Retreiving Partial content of a file
1 posts in topic
Flat View  Flat View

Posted By:   Ravi_Kumar
Posted On:   Saturday, December 7, 2002 08:23 AM

Hello Friends,
I want to retreive partial content of a file from an URL.I want to download a file in segments and then recombine it for the original file.
Any suggestions are appreciated.

Re: Retreiving Partial content of a file

Posted By:   pushkar_prakash  
Posted On:   Saturday, December 7, 2002 11:21 AM

It looks like you wish to accelerate your downloads.

This should work.

1. get the file size from the server.(let it be n)

2. decide on the number of fragments you want to divide the file into.( let it be m)

3. now calculate the size of each fragment of the file to be downloaded.(a1,a2,..,am)

4. open m different input streams.(to actually accelerate the download you should download each fragment in a seperate thread)

5. now read from each input stream but before reading use
InputStream.skip(long no.of bytes to be skipped ; 0 for the first inputstream) so that you read only the specific block.

6. each thread should signal the main thread when it is one.

7. the main thread should keep track of messagess from the child threads.

8. when the main thread finds that all the threads have returned successfully it should combine the file fragments to get the main file.

Best Regards,
About | Sitemap | Contact