1 16 package org.apache.commons.io.output; 17 18 import java.io.IOException ; 19 import java.io.OutputStream ; 20 21 28 public class DemuxOutputStream 29 extends OutputStream 30 { 31 private InheritableThreadLocal m_streams = new InheritableThreadLocal (); 32 33 39 public OutputStream bindStream( OutputStream output ) 40 { 41 OutputStream stream = getStream(); 42 m_streams.set( output ); 43 return stream; 44 } 45 46 51 public void close() 52 throws IOException 53 { 54 OutputStream output = getStream(); 55 if( null != output ) 56 { 57 output.close(); 58 } 59 } 60 61 66 public void flush() 67 throws IOException 68 { 69 OutputStream output = getStream(); 70 if( null != output ) 71 { 72 output.flush(); 73 } 74 } 75 76 82 public void write( int ch ) 83 throws IOException 84 { 85 OutputStream output = getStream(); 86 if( null != output ) 87 { 88 output.write( ch ); 89 } 90 } 91 92 95 private OutputStream getStream() 96 { 97 return (OutputStream )m_streams.get(); 98 } 99 } 100 | Popular Tags |