1 16 package org.apache.commons.io.input; 17 18 import java.io.IOException ; 19 import java.io.InputStream ; 20 21 28 public class DemuxInputStream 29 extends InputStream 30 { 31 private InheritableThreadLocal m_streams = new InheritableThreadLocal (); 32 33 39 public InputStream bindStream( InputStream input ) 40 { 41 InputStream oldValue = getStream(); 42 m_streams.set( input ); 43 return oldValue; 44 } 45 46 51 public void close() 52 throws IOException 53 { 54 InputStream input = getStream(); 55 if( null != input ) 56 { 57 input.close(); 58 } 59 } 60 61 67 public int read() 68 throws IOException 69 { 70 InputStream input = getStream(); 71 if( null != input ) 72 { 73 return input.read(); 74 } 75 else 76 { 77 return -1; 78 } 79 } 80 81 84 private InputStream getStream() 85 { 86 return (InputStream )m_streams.get(); 87 } 88 } 89 | Popular Tags |