01: /*
02: * TeeOutputStream.java
03: *
04: * Created on September 15, 2006, 3:09 PM
05: *
06: * The contents of this file are subject to the terms
07: * of the Common Development and Distribution License
08: * (the License). You may not use this file except in
09: * compliance with the License.
10: *
11: * You can obtain a copy of the license at
12: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
13: * See the License for the specific language governing
14: * permissions and limitations under the License.
15: *
16: * When distributing Covered Code, include this CDDL
17: * Header Notice in each file and include the License file
18: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
19: * If applicable, add the following below the CDDL Header,
20: * with the fields enclosed by brackets [] replaced by
21: * you own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
25: */
26:
27: package com.sun.xml.ws.security.opt.impl.util;
28:
29: import java.io.IOException;
30: import java.io.OutputStream;
31:
32: /**
33: *
34: * @author Ashutosh.Shahi@sun.com
35: */
36: public class TeeOutputStream extends OutputStream {
37:
38: OutputStream tee = null;
39: OutputStream out = null;
40:
41: /** Creates a new instance of TeeOutputStream */
42: public TeeOutputStream(OutputStream chainedStream,
43: OutputStream teeStream) {
44: out = chainedStream;
45: tee = teeStream;
46: }
47:
48: public void write(int b) throws IOException {
49: out.write(b);
50: tee.write(b);
51: }
52:
53: public void close() throws IOException {
54: flush();
55: out.close();
56: tee.close();
57: }
58:
59: public void flush() throws IOException {
60: out.flush();
61: tee.flush();
62: }
63: }
|