Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jguild.jrpm.test
Class StreamGobbler  view StreamGobbler download StreamGobbler.java

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.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 Class Summary
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  java.io.InputStream is
           
(package private)  java.io.OutputStream os
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamGobbler(java.io.InputStream is)
          Creates a new StreamGobbler object for a given input stream
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.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

is

java.io.InputStream is

os

java.io.OutputStream os
Constructor Detail

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.

Method Detail

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.