commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ma...@ops.co.at>
Subject Re: commons-vfs and bandwidth
Date Mon, 16 Oct 2006 10:08:52 GMT
Hi zizou77!
> how you can couting input/ouput stream.
> it's with commons-vfs?
>   
No, you just create your own CountingInputStream, maybe best by inherit
from FilterInputStream, override the read(...) methods and add the
number of bytes read to a counter.
On the first read(...) you store the System.currentTimeMillis() and
later you can use both informations (nuof read bytes and time) to
calculate a bandwith.

The same goes for OutputStream.

Best is you create another class, say "BandwithManager" where the nuof
bytes and the start time lives, maybe separated by read/write or both.
You pass an instance of your BandwithManager to the constructor of your
Counting*Stream and then you can have e.g.
BandwithManager.getInputBandwith(), BandwithManager.getOutputBandwith(),
BandwithManager.getTotalBandwith()

Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message