|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
TeeOutputStream.java | - | 71.4% | 66.7% | 70% |
|
1 |
// Copyright 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.util.io;
|
|
16 |
|
|
17 |
import java.io.IOException;
|
|
18 |
import java.io.OutputStream;
|
|
19 |
|
|
20 |
import org.apache.hivemind.util.Defense;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* An output stream that copies bytes pushed through it to two other output streams.
|
|
24 |
*
|
|
25 |
* @author Howard M. Lewis Ship
|
|
26 |
* @since 4.0
|
|
27 |
*/
|
|
28 |
public class TeeOutputStream extends OutputStream |
|
29 |
{ |
|
30 |
private final OutputStream _os1;
|
|
31 |
|
|
32 |
private final OutputStream _os2;
|
|
33 |
|
|
34 | 3 |
public TeeOutputStream(OutputStream os1, OutputStream os2)
|
35 |
{ |
|
36 | 3 |
Defense.notNull(os1, "os1");
|
37 | 3 |
Defense.notNull(os2, "os2");
|
38 |
|
|
39 | 3 |
_os1 = os1; |
40 | 3 |
_os2 = os2; |
41 |
} |
|
42 |
|
|
43 | 2 |
public void close() throws IOException |
44 |
{ |
|
45 | 2 |
_os1.close(); |
46 | 2 |
_os2.close(); |
47 |
} |
|
48 |
|
|
49 | 6 |
public void flush() throws IOException |
50 |
{ |
|
51 | 6 |
_os1.flush(); |
52 | 6 |
_os2.flush(); |
53 |
} |
|
54 |
|
|
55 | 6 |
public void write(byte[] b, int off, int len) throws IOException |
56 |
{ |
|
57 | 6 |
_os1.write(b, off, len); |
58 | 6 |
_os2.write(b, off, len); |
59 |
} |
|
60 |
|
|
61 | 0 |
public void write(byte[] b) throws IOException |
62 |
{ |
|
63 | 0 |
_os1.write(b); |
64 | 0 |
_os1.write(b); |
65 |
} |
|
66 |
|
|
67 | 0 |
public void write(int b) throws IOException |
68 |
{ |
|
69 | 0 |
_os1.write(b); |
70 | 0 |
_os2.write(b); |
71 |
} |
|
72 |
} |
|