1 50 package org.apache.avalon.excalibur.io; 51 52 import java.io.IOException ; 53 import java.io.InputStream ; 54 55 62 public final class DemuxInputStream 63 extends InputStream 64 { 65 private final InheritableThreadLocal m_streams = new InheritableThreadLocal (); 66 67 72 public InputStream bindStream( final InputStream input ) 73 { 74 final InputStream oldValue = getStream(); 75 m_streams.set( input ); 76 return oldValue; 77 } 78 79 84 public void close() 85 throws IOException 86 { 87 final InputStream input = getStream(); 88 if( null != input ) 89 { 90 input.close(); 91 } 92 } 93 94 100 public int read() 101 throws IOException 102 { 103 final InputStream input = getStream(); 104 if( null != input ) 105 { 106 return input.read(); 107 } 108 else 109 { 110 return -1; 111 } 112 } 113 114 117 private InputStream getStream() 118 { 119 return (InputStream )m_streams.get(); 120 } 121 } 122 | Popular Tags |