System.nanotime and Applet
Hello all,
I'm creating an applet to upload potentially big files to a HTTP server.
As uploading may take some time, I would like to show the user the speed and eta of the upload.
Here is my code :
while ((n = fi.read(buff)) > 0){
startTime = System.nanoTime();
this.output.write(buff, 0, n);
this.output.flush();
estimatedTime = System.nanoTime() - startTime;
curSpeed = ((double) n * 1000 / (double) estimatedTime) * 1000000;
[...]
}
An average of curSpeed is then calculated and shown to the user.
This code works perfectly well in the applet viewer, but when I run it in the browser, I get a totally wrong speed (I get approximatly 40MB/s instead of 100KB/s).
What could possibly cause this?
Any help would be greatly appreciated.
--
strawks.

