deleted
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.
deleted
Last edited by Koâk; May 21st, 2014 at 03:44 AM.
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; }
deleted
Last edited by Koâk; May 21st, 2014 at 03:45 AM.