ini.trakem2.io
Class LoggingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by ini.trakem2.io.LoggingInputStream
All Implemented Interfaces:
java.io.Closeable

public class LoggingInputStream
extends java.io.BufferedInputStream

A class to monitor an input stream for speed and total byte download.


Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
LoggingInputStream(java.io.InputStream in)
           
 
Method Summary
 void getInfo(long[] info)
          Returns info as [0] = current time in ms [1] = elapsed time in ms since last call to getInfo(long[]) [2] = n_bytes_read since last call to getInfo(long[]) [3] = accumulated time in ms since last call to resetInfo() [4] = accumulated bytes since last call to resetInfo() So current speed = info[2]/info[1] Kb/s
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void resetInfo()
          Put the counter to zero.
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingInputStream

public LoggingInputStream(java.io.InputStream in)
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.BufferedInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.BufferedInputStream
Throws:
java.io.IOException

resetInfo

public void resetInfo()
Put the counter to zero.


getInfo

public void getInfo(long[] info)
Returns info as [0] = current time in ms [1] = elapsed time in ms since last call to getInfo(long[]) [2] = n_bytes_read since last call to getInfo(long[]) [3] = accumulated time in ms since last call to resetInfo() [4] = accumulated bytes since last call to resetInfo() So current speed = info[2]/info[1] Kb/s