diff options
| author | J08nY | 2017-10-14 01:14:07 +0200 |
|---|---|---|
| committer | J08nY | 2017-10-15 00:19:18 +0200 |
| commit | 114c3378e323b954bfd8c0470e489c9615978d58 (patch) | |
| tree | 46281a9f45c91bdad518e7e21e5edff099b96c01 /src/cz/crcs/ectester/reader/output/TeeOutputStream.java | |
| parent | 88f829e238097343a044f437c2d4cfeb8b6cfdff (diff) | |
| download | ECTester-114c3378e323b954bfd8c0470e489c9615978d58.tar.gz ECTester-114c3378e323b954bfd8c0470e489c9615978d58.tar.zst ECTester-114c3378e323b954bfd8c0470e489c9615978d58.zip | |
Refactor response and test outputing into separate writers.
This is done to provide multiple output formats, one which logs
tests to console in simple human readable format and others.
Diffstat (limited to 'src/cz/crcs/ectester/reader/output/TeeOutputStream.java')
| -rw-r--r-- | src/cz/crcs/ectester/reader/output/TeeOutputStream.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/reader/output/TeeOutputStream.java b/src/cz/crcs/ectester/reader/output/TeeOutputStream.java new file mode 100644 index 0000000..e18d32b --- /dev/null +++ b/src/cz/crcs/ectester/reader/output/TeeOutputStream.java @@ -0,0 +1,36 @@ +package cz.crcs.ectester.reader.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * @author Jan Jancar johny@neuromancer.sk + */ +public class TeeOutputStream extends OutputStream { + private OutputStream[] outputs; + + public TeeOutputStream(OutputStream... outputs) { + this.outputs = outputs; + } + + @Override + public void write(int b) throws IOException { + for (OutputStream out : outputs) { + out.write(b); + } + } + + @Override + public void flush() throws IOException { + for (OutputStream out :outputs) { + out.flush(); + } + } + + @Override + public void close() throws IOException { + for (OutputStream out :outputs) { + out.close(); + } + } +} |
