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