Package net.targetr.wtm3.io
Class MonitoredOutputStream
java.lang.Object
java.io.OutputStream
net.targetr.wtm3.io.MonitoredOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Keeps track of how many bytes are written to an output stream.
Used for statistical purposes.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
ConstructorsConstructorDescriptionMonitoredOutputStream(OutputStream out, AtomicLong counter) Decorates a stream with the ability to monitor how much data is transferred. -
Method Summary
Modifier and TypeMethodDescriptionbooleanFor detecting if the response has started.voidclose()voidflush()voidsetInterception(OutputStream interception) Adds an output stream to receive data written to this output stream.toString()voidwrite(byte[] data, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
MonitoredOutputStream
Decorates a stream with the ability to monitor how much data is transferred.- Parameters:
out- The output stream to monitor.counter- The counter that should be incremented.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
toString
-
canRelayError
public boolean canRelayError()For detecting if the response has started. If a response has started we can not write an error response.- Returns:
- true if an error can be sent on the input stream.
-
setInterception
Adds an output stream to receive data written to this output stream.- Parameters:
interception- where to send intercepted data.
-