Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 Tristan Tarrant Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package net.dataforte.commons.io;
 
 import java.util.List;

An java.io.OutputStream which "multiplexes" output to multiple underlying OuputStreams: all operations (write, flush, close) performed on the TeeOutputStream are passed down to the child OutputStreams.

Author(s):
Tristan Tarrant
 
 public class TeeOutputStream extends OutputStream {
Simple constructor. Use add(java.io.OutputStream) to add child OutputStreams
 
 	public TeeOutputStream() {
 	};


Constructor which takes a variable number of OutputStream parameters and adds them as children to this TeeOutputStream

Parameters:
ss a var-arg list of OutputStreams
 
 	public TeeOutputStream(OutputStream... ss) {
 		for(OutputStream s : ss) {
 			.add(s);
 		}
 	}

Adds a new OutputStream to the list of child OutputStreams

Parameters:
s
 
 	public void add(OutputStream s) {
 		if (s != null) {
 			.add(s);
 		}
 	}
 
 	public void write(int bthrows IOException {
 		for (OutputStream s : ) {
 			s.write(b);
 		}
 	}
 
 	public void close() throws IOException {
 		for (OutputStream s : ) {
 			s.close();
 		}
 	}
 
 	public void flush() throws IOException {
 		for (OutputStream s : ) {
 			s.flush();
 		}
 	}
 
 	public void write(byte[] bint offint lenthrows IOException {
 		for (OutputStream s : ) {
 			s.write(bofflen);
 		}
 	}
 
 	public void write(byte[] bthrows IOException {
 		for (OutputStream s : ) {
 			s.write(b);
 		}
 	}
New to GrepCode? Check out our FAQ X