diff options
Diffstat (limited to 'src/main/java/bjc/everge/MirrorOutputStream.java')
| -rw-r--r-- | src/main/java/bjc/everge/MirrorOutputStream.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/bjc/everge/MirrorOutputStream.java b/src/main/java/bjc/everge/MirrorOutputStream.java new file mode 100644 index 0000000..6718bd7 --- /dev/null +++ b/src/main/java/bjc/everge/MirrorOutputStream.java @@ -0,0 +1,46 @@ +package bjc.everge; + +import java.io.*; +import java.util.*; + +public class MirrorOutputStream extends OutputStream { + private List<OutputStream> streams; + + public MirrorOutputStream(OutputStream... strams) { + streams = new ArrayList<>(); + + for (OutputStream stram : strams) { + streams.add(stram); + } + } + + public void close() throws IOException { + for (OutputStream stream : streams) { + stream.close(); + } + } + + public void flush() throws IOException { + for (OutputStream stream : streams) { + stream.flush(); + } + } + + public void write(byte[] ba) throws IOException { + for (OutputStream stream : streams) { + stream.write(ba); + } + } + + public void write(byte[] ba, int off, int len) throws IOException { + for (OutputStream stream : streams) { + stream.write(ba, off, len); + } + } + + public void write(int b) throws IOException { + for (OutputStream stream : streams) { + stream.write(b); + } + } +} |
