net.sf.taverna.t2.lang.io
Class StreamDevourer

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.taverna.t2.lang.io.StreamDevourer
All Implemented Interfaces:
java.lang.Runnable

public class StreamDevourer
extends java.lang.Thread

Devours an input stream and allows the contents to be read as a String once the stream has completed.

Author:
Tom Oinn

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamDevourer(java.io.InputStream is)
          Create the StreamDevourer and point it at an InputStream to consume
 
Method Summary
 java.lang.String blockOnOutput()
          Waits for the stream to close then returns the String representation of its contents (this is equivalent to doing a join then calling toString)
 void run()
          When started this Thread will copy all data from the InputStream into a ByteArrayOutputStream via a BufferedReader.
 java.lang.String toString()
          Returns the current value of the internal ByteArrayOutputStream
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamDevourer

public StreamDevourer(java.io.InputStream is)
Create the StreamDevourer and point it at an InputStream to consume

Method Detail

toString

public java.lang.String toString()
Returns the current value of the internal ByteArrayOutputStream

Overrides:
toString in class java.lang.Thread

blockOnOutput

public java.lang.String blockOnOutput()
Waits for the stream to close then returns the String representation of its contents (this is equivalent to doing a join then calling toString)


run

public void run()
When started this Thread will copy all data from the InputStream into a ByteArrayOutputStream via a BufferedReader. Because of the use of the BufferedReader this is only really appropriate for streams of textual data

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread