summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/everge/MirrorOutputStream.java
blob: 6718bd7d7ef3e58a293f8f3c1c3d5cc7d6972d75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
		}
	}
}