public class StreamGobbler extends Thread
Captures the output of an InputStream.
With acknowledgements to Michael C. Daconta, author of "Java Pitfalls, Time Saving Solutions, and Workarounds to Improve Programs." and his article in JavaWorld "When Runtime.exec() Won't". See the ExecRunner class for a reference implementation.Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
StreamGobbler()
Basic constructor for StreamGobbler.
|
StreamGobbler(InputStream in)
A simpler constructor for StreamGobbler - defaults to
System.out |
StreamGobbler(InputStream in,
OutputStream out)
A more explicit constructor for StreamGobbler where you can tell it
exactly where to relay the output to.
|
StreamGobbler(InputStream in,
PrintWriter pwOut)
A more explicit constructor for StreamGobbler where you can tell it
exactly where to relay the output to.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
We override the
clone method here to prevent cloning of
our class. |
void |
quit()
Tells the StreamGobbler to quit it's operation.
|
void |
run()
Gobbles up all the stuff coming from the InputStream and sends it to the
OutputStream specified during object construction.
|
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, toString, yield
public StreamGobbler()
public StreamGobbler(InputStream in)
System.out
in
- InputStreampublic StreamGobbler(InputStream in, OutputStream out)
in
- InputStreamout
- OutputStreampublic StreamGobbler(InputStream in, PrintWriter pwOut)
in
- InputStreampwOut
- PrintWriterpublic final Object clone() throws CloneNotSupportedException
clone
method here to prevent cloning of
our class.clone
in class Thread
CloneNotSupportedException
- To indicate cloning is not allowedpublic void quit()
Copyright © 2021. All rights reserved.