DemuxInputStream (Commons IO 2.5)
Date: 2016-12-01

org.apache.commons.io.input

## Class DemuxInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.commons.io.input.DemuxInputStream

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class DemuxInputStream
      extends java.io.InputStream

  Data written to this stream is forwarded to a stream that has been associated with this thread.
  Version:
    $Id: DemuxInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.InheritableThreadLocal<java.io.InputStream>` | `m_streams`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DemuxInputStream()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.io.InputStream` | `bindStream(java.io.InputStream input)` Bind the specified stream to the current thread.
    `void` | `close()` Closes stream associated with current thread.
    `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 final java.lang.InheritableThreadLocal<java.io.InputStream> m_streams

  - ### Constructor Detail

    - #### DemuxInputStream

          public DemuxInputStream()

  - ### Method Detail

    - #### bindStream

          public java.io.InputStream bindStream(java.io.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 java.io.IOException

      Closes stream associated with current thread.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`
      Throws:
        `java.io.IOException` - if an error occurs

    - #### read

          public int read()
                   throws java.io.IOException

      Read byte from stream associated with current thread.
      Specified by:
        `read` in class `java.io.InputStream`
      Returns:
        the byte read from stream
      Throws:
        `java.io.IOException` - if an error occurs

Copyright (c) 2002-2016 Apache Software Foundation