java.lang.Object
java.lang.Thread
com.jguild.jrpm.test.StreamGobbler
- All Implemented Interfaces:
- java.lang.Runnable
- public class StreamGobbler
- extends java.lang.Thread
This class reads an input stream in an extra thread. This is
used for running external programms out of java so that stdout
and stderr are not blocking the process from work. If the
stream is closed by Runtime the gobbler will also die.
Usage:
Process proc = Runtime.getRuntime().exec(command);
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(rpmProc.getErrorStream(), System.err);
// any output?
StreamGobbler outputGobbler = new StreamGobbler(rpmProc.getInputStream(), System.out);
// kick them off
errorGobbler.start();
outputGobbler.start();
- Version:
- $Revision: 1.2 $
| Nested classes inherited from class java.lang.Thread |
java.lang.Thread.UncaughtExceptionHandler |
|
Method Summary |
void |
run()
The method of Thread that will be run if there is no Runnable object
associated with the Thread. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
is
java.io.InputStream is
os
java.io.OutputStream os
StreamGobbler
public StreamGobbler(java.io.InputStream is)
- Creates a new StreamGobbler object for a given input stream
StreamGobbler
public StreamGobbler(java.io.InputStream is,
java.io.OutputStream redirect)
- Creates a new StreamGobbler object for a given input stream
that will be redirected to the defined output stream.
run
public void run()
- Description copied from class:
java.lang.Thread
- The method of Thread that will be run if there is no Runnable object
associated with the Thread. Thread's implementation does nothing at all.