001 package de.kumpe.hadooptimizer.examples; 002 003 import java.io.IOException; 004 import java.io.OutputStream; 005 006 public class TeeOutputStream extends OutputStream { 007 private final OutputStream first; 008 private final OutputStream second; 009 010 public TeeOutputStream(final OutputStream first, final OutputStream second) { 011 this.first = first; 012 this.second = second; 013 } 014 015 @Override 016 public void close() throws IOException { 017 first.close(); 018 second.close(); 019 } 020 021 @Override 022 public void flush() throws IOException { 023 first.flush(); 024 second.flush(); 025 } 026 027 @Override 028 public void write(final byte[] b) throws IOException { 029 first.write(b); 030 second.write(b); 031 } 032 033 @Override 034 public void write(final byte[] b, final int off, final int len) 035 throws IOException { 036 first.write(b, off, len); 037 second.write(b, off, len); 038 } 039 040 @Override 041 public void write(final int b) throws IOException { 042 first.write(b); 043 second.write(b); 044 } 045 }