monitor download progress in Java

J

james.cssa

Hi,

I want to write some code to download some file and monitor the
download progress. I have an HttpURLConnection to the file I want to
download, but the contentLength is -1 for the connection, which means
unknown file size. Nevertherless, I can download the file w/o problems.
So how can I monitor the progress of a download in terms of percentage
completed? Thank you!

James
 
A

Andrew Thompson

I want to write some code to download some file and monitor the
download progress. I have an HttpURLConnection to the file

When you say 'the file', do you mean it is always one
*specific* file that the application requests?

Is the file an application resource/What does it contain?

Andrew T.
 
J

james.cssa

Andrew said:
When you say 'the file', do you mean it is always one
*specific* file that the application requests?

Is the file an application resource/What does it contain?

Andrew T.

Hi Andrew,

It's always the same url, which points to a log file. The content of
the log file changes as logs are appended.
 
A

Andrew Thompson

...
It's always the same url, which points to a log file. The content of
the log file changes as logs are appended.

OK. That is very different to what I expected to hear,
and the problem is now more clear to me.

I suggest this general strategy..
Let the user see progress, by regularly updating the
text component in which the log will be displayed,
then scroll to the bottom as soon as you do the update.

Nothing indicates progress better than the data
actually appearing before your eyes!
(Think of a browser as it 'fills in' a web page and
the images on the page, progressively.)

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top