public synchronized InputStream getInputStream ( int stream ) { if ( state == State . CLOSED ) throw new IllegalStateException ( ) ; if ( ! input . containsKey ( stream ) ) { try { PipedInputStream pipeIn = new PipedInputStream ( ) ; PipedOutputStream pipeOut = new PipedOutputStream ( pipeIn ) ; pipedOutput . put ( stream , pipeOut ) ; input . put ( stream , pipeIn ) ; } catch ( IOException ex ) { // This is _very_ unlikely, as it requires the above constructor to fail. // don't force callers to catch, but still throw throw new IllegalStateException ( ex ) ; } } return input . get ( stream ) ; }
Get a specific input stream using its identifier . Caller is responsible for closing these streams .