org.apache.commons.io.input
Class DemuxInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.commons.io.input.DemuxInputStream
All Implemented Interfaces:
Closeable

public class DemuxInputStream
extends InputStream

Data written to this stream is forwarded to a stream that has been associated with this thread.

Version:
$Revision: 437567 $ $Date: 2006-08-28 08:39:07 +0200 (Mo, 28 Aug 2006) $
Author:
Peter Donald

Field Summary
private  InheritableThreadLocal m_streams
           
 
Constructor Summary
DemuxInputStream()
           
 
Method Summary
 InputStream bindStream(InputStream input)
          Bind the specified stream to the current thread.
 void close()
          Closes stream associated with current thread.
private  InputStream getStream()
          Utility method to retrieve stream bound to current thread (if any).
 int read()
          Read byte from stream associated with current thread.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_streams

private InheritableThreadLocal m_streams
Constructor Detail

DemuxInputStream

public DemuxInputStream()
Method Detail

bindStream

public InputStream bindStream(InputStream input)
Bind the specified stream to the current thread.

Parameters:
input - the stream to bind
Returns:
the InputStream that was previously active

close

public void close()
           throws IOException
Closes stream associated with current thread.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException - if an error occurs

read

public int read()
         throws IOException
Read byte from stream associated with current thread.

Specified by:
read in class InputStream
Returns:
the byte read from stream
Throws:
IOException - if an error occurs

getStream

private InputStream getStream()
Utility method to retrieve stream bound to current thread (if any).

Returns:
the input stream