1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.io;
20
21 import java.io.IOException;
22 import java.io.OutputStream;
23
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25
26
27
28
29
30
31
32 @InterfaceAudience.Private
33 public class DoubleOutputStream extends OutputStream {
34 private OutputStream out1;
35 private OutputStream out2;
36
37 public DoubleOutputStream(OutputStream out1, OutputStream out2) {
38 this.out1 = out1;
39 this.out2 = out2;
40 }
41
42 @Override
43 public void write(int b) throws IOException {
44 out1.write(b);
45 out2.write(b);
46 }
47
48 @Override
49 public void write(byte b[]) throws IOException {
50 out1.write(b, 0, b.length);
51 out2.write(b, 0, b.length);
52 }
53
54 @Override
55 public void write(byte b[], int off, int len) throws IOException {
56 out1.write(b, off, len);
57 out2.write(b, off, len);
58 }
59
60 @Override
61 public void flush() throws IOException {
62 out1.flush();
63 out2.flush();
64 }
65
66 @Override
67 public void close() throws IOException {
68 try {
69 out1.close();
70 } finally {
71
72 out2.close();
73 }
74 }
75
76 }