2 * ============LICENSE_START====================================================
\r
4 * ===========================================================================
\r
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
\r
6 * ===========================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END====================================================
\r
22 package org.onap.aaf.misc.env.util;
\r
24 import java.io.IOException;
\r
25 import java.io.OutputStream;
\r
27 public class DoubleOutputStream extends OutputStream {
\r
28 private OutputStream[] oss;
\r
29 private boolean[] close;
\r
32 * Create a Double Stream Writer
\r
33 * Some Streams should not be closed by this object (i.e. System.out), therefore, mark them with booleans
\r
35 public DoubleOutputStream(OutputStream a, boolean closeA, OutputStream b, boolean closeB) {
\r
36 oss = new OutputStream[] {a,b};
\r
37 close = new boolean[] {closeA,closeB};
\r
41 * Write a single character.
\r
42 * @throws IOException
\r
45 public void write(int c) throws IOException {
\r
46 for(OutputStream os : oss) {
\r
52 * Write a portion of an array of characters.
\r
54 * @param bbuf Array of characters
\r
55 * @param off Offset from which to start writing characters
\r
56 * @param len Number of characters to write
\r
57 * @throws IOException
\r
60 public void write(byte bbuf[], int off, int len) throws IOException {
\r
61 for(OutputStream os : oss) {
\r
62 os.write(bbuf,off,len);
\r
67 public void write(byte[] b) throws IOException {
\r
68 for(OutputStream os : oss) {
\r
74 * @see java.io.OutputStream#close()
\r
77 public void close() throws IOException {
\r
78 for(int i=0;i<oss.length;++i) {
\r
86 * @see java.io.OutputStream#flush()
\r
89 public void flush() throws IOException {
\r
90 for(OutputStream os : oss) {
\r