001 package railo.commons.io; 002 003 import java.io.IOException; 004 import java.io.OutputStream; 005 006 public final class ForkOutputStream extends OutputStream { 007 008 private final OutputStream os1; 009 private final OutputStream os2; 010 011 public ForkOutputStream(OutputStream os1,OutputStream os2) { 012 this.os1=os1; 013 this.os2=os2; 014 } 015 016 /** 017 * 018 * @see java.io.OutputStream#close() 019 */ 020 public void close() throws IOException { 021 try { 022 os1.close(); 023 } 024 finally { 025 os2.close(); 026 } 027 } 028 029 /** 030 * 031 * @see java.io.OutputStream#flush() 032 */ 033 public void flush() throws IOException { 034 try { 035 os1.flush(); 036 } 037 finally { 038 os2.flush(); 039 } 040 } 041 042 /** 043 * 044 * @see java.io.OutputStream#write(byte[], int, int) 045 */ 046 public void write(byte[] b, int off, int len) throws IOException { 047 os1.write(b, off, len); 048 os2.write(b, off, len); 049 } 050 051 /** 052 * 053 * @see java.io.OutputStream#write(byte[]) 054 */ 055 public void write(byte[] b) throws IOException { 056 os1.write(b); 057 os2.write(b); 058 } 059 060 public void write(int b) throws IOException { 061 os1.write(b); 062 os2.write(b); 063 } 064 065 }