Package net.targetr.wtm3.io
Class MonitoredInputStream
java.lang.Object
java.io.InputStream
net.targetr.wtm3.io.MonitoredInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Keeps track of how many bytes are read from an input stream.
Used for statistical purposes.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
ConstructorsConstructorDescriptionMonitoredInputStream(InputStream in, AtomicLong counter) Decorates a stream with the ability to monitor how much data is transferred. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intread()intread(byte[] data, int off, int len) voidsetInterception(OutputStream interception) Adds an output stream to receive data received on this output stream.Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
MonitoredInputStream
Decorates a stream with the ability to monitor how much data is transferred.- Parameters:
in- The input stream to monitor.counter- The counter that should be incremented.
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
setInterception
Adds an output stream to receive data received on this output stream.- Parameters:
interception- where to send intercepted data.
-