/** * Bind the specified stream to the current thread. * * @param output the stream to bind * @return the OutputStream that was previously active */ public OutputStream bindStream( OutputStream output ) { OutputStream stream = getStream(); m_streams.set( output ); return stream; }
@Override public void run() { m_demux.bindStream(m_output); for (final byte element : m_data) { try { //System.out.println( "Writing: " + (char)m_data[ i ] ); m_demux.write(element); final int sleepTime = Math.abs(c_random.nextInt() % 10); TestUtils.sleep(sleepTime); } catch (final Exception e) { e.printStackTrace(); } } } }
@Test public void testOutputStream() throws Exception { final DemuxOutputStream output = new DemuxOutputStream(); startWriter(T1, DATA1, output); startWriter(T2, DATA2, output); startWriter(T3, DATA3, output); startWriter(T4, DATA4, output); doStart(); doJoin(); assertEquals("Data1", DATA1, getOutput(T1)); assertEquals("Data2", DATA2, getOutput(T2)); assertEquals("Data3", DATA3, getOutput(T3)); assertEquals("Data4", DATA4, getOutput(T4)); }
/** * Flushes stream associated with current thread. * * @throws IOException if an error occurs */ public void flush() throws IOException { OutputStream output = getStream(); if( null != output ) { output.flush(); } }
/** * Closes stream associated with current thread. * * @throws IOException if an error occurs */ public void close() throws IOException { OutputStream output = getStream(); if( null != output ) { output.close(); } }
/** * Writes byte to stream associated with current thread. * * @param ch the byte to write to stream * @throws IOException if an error occurs */ public void write( int ch ) throws IOException { OutputStream output = getStream(); if( null != output ) { output.write( ch ); } }
/** * Bind the specified stream to the current thread. * * @param output the stream to bind * @return the OutputStream that was previously active */ public OutputStream bindStream( OutputStream output ) { OutputStream stream = getStream(); m_streams.set( output ); return stream; }
/** * Bind the specified stream to the current thread. * * @param output the stream to bind * @return the OutputStream that was previously active */ public OutputStream bindStream( OutputStream output ) { OutputStream stream = getStream(); m_streams.set( output ); return stream; }
/** * Closes stream associated with current thread. * * @throws IOException if an error occurs */ public void close() throws IOException { OutputStream output = getStream(); if( null != output ) { output.close(); } }
/** * Flushes stream associated with current thread. * * @throws IOException if an error occurs */ public void flush() throws IOException { OutputStream output = getStream(); if( null != output ) { output.flush(); } }
/** * Closes stream associated with current thread. * * @throws IOException if an error occurs */ public void close() throws IOException { OutputStream output = getStream(); if( null != output ) { output.close(); } }
/** * Flushes stream associated with current thread. * * @throws IOException if an error occurs */ public void flush() throws IOException { OutputStream output = getStream(); if( null != output ) { output.flush(); } }
/** * Writes byte to stream associated with current thread. * * @param ch the byte to write to stream * @throws IOException if an error occurs */ public void write( int ch ) throws IOException { OutputStream output = getStream(); if( null != output ) { output.write( ch ); } }
/** * Writes byte to stream associated with current thread. * * @param ch the byte to write to stream * @throws IOException if an error occurs */ public void write( int ch ) throws IOException { OutputStream output = getStream(); if( null != output ) { output.write( ch ); } }