1 52 53 package com.go.trove.io; 54 55 import java.io.IOException ; 56 import java.io.OutputStream ; 57 58 67 68 public class DualOutput extends OutputStream { 69 private OutputStream mOut1; 70 private OutputStream mOut2; 71 72 public DualOutput(OutputStream out1, OutputStream out2) { 73 mOut1 = out1; 74 mOut2 = out2; 75 } 76 77 public void write(int b) throws IOException { 78 try { 79 mOut1.write(b); 80 } 81 finally { 82 mOut2.write(b); 83 } 84 } 85 86 public void write(byte[] b, int off, int len) throws IOException { 87 try { 88 mOut1.write(b, off, len); 89 } 90 finally { 91 mOut2.write(b, off, len); 92 } 93 } 94 95 public void flush() throws IOException { 96 try { 97 mOut1.flush(); 98 } 99 finally { 100 mOut2.flush(); 101 } 102 } 103 104 public void close() throws IOException { 105 try { 106 mOut1.close(); 107 } 108 finally { 109 mOut2.close(); 110 } 111 } 112 } 113 | Popular Tags |