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 TypeMethodDescriptionvoid
close()
int
read()
int
read
(byte[] data, int off, int len) void
setInterception
(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:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
setInterception
Adds an output stream to receive data received on this output stream.- Parameters:
interception
- where to send intercepted data.
-