monitor download progress in Java

Discussion in 'Java' started by james.cssa@gmail.com, Jan 16, 2007.

  1. Guest

    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
     
    , Jan 16, 2007
    #1
    1. Advertising

  2. wrote:
    ...
    > 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.
     
    Andrew Thompson, Jan 17, 2007
    #2
    1. Advertising

  3. Guest

    Andrew Thompson wrote:
    > wrote:
    > ..
    > > 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.


    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.
     
    , Jan 17, 2007
    #3
  4. wrote:
    > Andrew Thompson wrote:
    > > wrote:
    > > ..
    > > > 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..?

    ...
    > 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.
     
    Andrew Thompson, Jan 17, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kaith

    Progress monitor is blank

    kaith, Sep 13, 2003, in forum: Java
    Replies:
    6
    Views:
    1,375
    Jezuch
    Sep 13, 2003
  2. Ajay Singh Tomar

    Progress Monitor

    Ajay Singh Tomar, Apr 15, 2004, in forum: Java
    Replies:
    1
    Views:
    471
    Christophe Vanfleteren
    Apr 15, 2004
  3. Charlie Zhang
    Replies:
    3
    Views:
    1,259
    Paul Lutus
    Aug 16, 2004
  4. ScottZ
    Replies:
    2
    Views:
    361
    Jorgen Grahn
    Nov 2, 2008
  5. Joao Silva
    Replies:
    4
    Views:
    213
    Choi, Junegunn
    Feb 9, 2009
Loading...

Share This Page