Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: KB/s download speed calculating

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    25
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default KB/s download speed calculating

    deleted
    Last edited by Koâk; May 21st, 2014 at 03:44 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: KB/s download speed calculating

    The actual implementation depends upon how you are downloading. Here's a way if you are downloading iteratively (eg you are using loops to download). Create a Timer that fires however often you wish to update the download speed in the GUI. Have a variable that holds the current download size and set it every run through the loop. Every time the timer fires subtract the previous size from the current size, and divide this by the number of seconds since the previous firing == bytes/s.

    int currentAmount = 0;//set this during each loop of the download
    /***/
    int previousAmount = 0;
    int firingTime = 1000;//in milliseconds, here fire every second
    public synchronyzed void run(){
        int bytesPerSecond = (currentAmount-previousAmount)/(firingTime/1000);
        //update GUI using bytesPerSecond
        previousAmount = currentAmount;    
    }

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    25
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: KB/s download speed calculating

    deleted
    Last edited by Koâk; May 21st, 2014 at 03:45 AM.

Similar Threads

  1. How to Download a file via FTP
    By JavaPF in forum Java Networking Tutorials
    Replies: 1
    Last Post: December 24th, 2011, 11:56 AM
  2. Facing problem with posting Excel file for download - Content in browser
    By ragz_82 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 9th, 2010, 08:28 AM
  3. Download a file to client from server
    By mvittalreddy in forum Java Networking
    Replies: 4
    Last Post: October 5th, 2009, 04:23 AM
  4. Replies: 4
    Last Post: June 18th, 2009, 09:23 AM
  5. Detecting File Download Completion
    By fedfan in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: June 5th, 2009, 04:27 AM