hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Brown" <chris92...@hotmail.com>
Subject RE: How i can get information about the downloading process?
Date Sun, 07 Nov 2004 09:00:09 GMT
Hi Gaspar,

If you use some of the approaches that let HTTPClient do all the hard work 
for you, you'll not have this feedback as far as I'm aware.

But it's quite simple to get this information yourself.  If you open the 
connection and read data as a stream, you need to remember :

* the time (e.g. System.currentTimeMillis()) you started as a "long" 

* the total number of bytes so far read as a "long" variable, updated each 
time you read some bytes from the stream

* you can determine the average speed so far by dividing the number of bytes 
downloaded by the time taken so far (see both points above); that's not 
necessarily your current speed

* for the percentage remaining, you'll need to know in advance the size of 
what you're going to download (the HTTP response header "Content-Length" 
should help here, but you're not always going to get this information, and 
it's not always provided correctly by the server).

You'll want multithreading no doubt, so make your "download" object expose 
this information through "getter" methods.  You can then display this on the 
command line, in a progress bar, or whatever.

- Chris

>From: "Gaspar" <gaspar@borderlessgroup.com>
>Reply-To: "HttpClient Project" <httpclient-dev@jakarta.apache.org>
>To: <httpclient-dev@jakarta.apache.org>
>Subject: How i can get information about the downloading process?
>Date: Sat, 6 Nov 2004 16:08:35 -0800
>My question is about how i can do with HttpClient, something that i see on
>many download manager software.
>About the file that i'm downloading using HttpClient i want to get this
>- % of the file that is downloaded already.
>- the size of what is downloaded already.
>- the speed rate(b/s) of what is downloading.
>- the time left to finish the download process.
>the downlaod manager that i use is ReGet Deluxe 3.3 and i want do something
>similar with HttpClient.
>Thanks in advance,
>To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org

MSN Actions Solidaires : volontaire à l'étranger 

To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org

View raw message