FileDocCategorySizeDatePackage
DemuxOutputStream.javaAPI DocAndroid 1.5 API2961Wed May 06 22:42:46 BST 2009org.apache.commons.io.output

DemuxOutputStream

public class DemuxOutputStream extends OutputStream
Data written to this stream is forwarded to a stream that has been associated with this thread.
author
Peter Donald
version
$Revision: 437567 $ $Date: 2006-08-28 07:39:07 +0100 (Mon, 28 Aug 2006) $

Fields Summary
private InheritableThreadLocal
m_streams
Constructors Summary
Methods Summary
public java.io.OutputStreambindStream(java.io.OutputStream output)
Bind the specified stream to the current thread.

param
output the stream to bind
return
the OutputStream that was previously active


                              
         
    
        OutputStream stream = getStream();
        m_streams.set( output );
        return stream;
    
public voidclose()
Closes stream associated with current thread.

throws
IOException if an error occurs

        OutputStream output = getStream();
        if( null != output )
        {
            output.close();
        }
    
public voidflush()
Flushes stream associated with current thread.

throws
IOException if an error occurs

        OutputStream output = getStream();
        if( null != output )
        {
            output.flush();
        }
    
private java.io.OutputStreamgetStream()
Utility method to retrieve stream bound to current thread (if any).

return
the output stream

        return (OutputStream)m_streams.get();
    
public voidwrite(int ch)
Writes byte to stream associated with current thread.

param
ch the byte to write to stream
throws
IOException if an error occurs

        OutputStream output = getStream();
        if( null != output )
        {
            output.write( ch );
        }