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) Sets a stream that receives a copy of bytes read from this input 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
Sets a stream that receives a copy of bytes read from this input stream.- Parameters:
interception- copy destination, or null to disable interception
-