1 50 package org.apache.avalon.excalibur.io; 51 52 import java.io.IOException ; 53 import java.io.OutputStream ; 54 55 62 public final class DemuxOutputStream 63 extends OutputStream 64 { 65 private final InheritableThreadLocal m_streams = new InheritableThreadLocal (); 66 67 72 public OutputStream bindStream( final OutputStream output ) 73 { 74 final OutputStream stream = getStream(); 75 m_streams.set( output ); 76 return stream; 77 } 78 79 84 public void close() 85 throws IOException 86 { 87 final OutputStream output = getStream(); 88 if( null != output ) 89 { 90 output.close(); 91 } 92 } 93 94 99 public void flush() 100 throws IOException 101 { 102 final OutputStream output = getStream(); 103 if( null != output ) 104 { 105 output.flush(); 106 } 107 } 108 109 115 public void write( final int ch ) 116 throws IOException 117 { 118 final OutputStream output = getStream(); 119 if( null != output ) 120 { 121 output.write( ch ); 122 } 123 } 124 125 128 private OutputStream getStream() 129 { 130 return (OutputStream )m_streams.get(); 131 } 132 } 133 | Popular Tags |