se.unlogic.standardutils.exec
Class StreamPrinter

java.lang.Object
  extended by java.lang.Thread
      extended by se.unlogic.standardutils.exec.StreamPrinter
All Implemented Interfaces:
Runnable, StreamHandler

public class StreamPrinter
extends Thread
implements StreamHandler

A simple buffered StreamHandler implementation that prints the input from the InputStream to the given OutputStream. If no OutputStream is given it defaults to System.out.

This implementation inputStream based on the PrintWriter, InputStreamReader and BufferedReader classes.

Author:
Robert "Unlogic" Olofsson (unlogic@unlogic.se)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamPrinter()
           
StreamPrinter(OutputStream os)
           
StreamPrinter(String prefix, OutputStream os)
           
 
Method Summary
 void awaitFinish()
           
 OutputStream getOutputStream()
           
 String getPrefix()
           
 void handleStream(InputStream is)
           
 boolean isFinished()
           
 boolean isTerminated()
           
 void run()
           
 void terminate()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamPrinter

public StreamPrinter(String prefix,
                     OutputStream os)

StreamPrinter

public StreamPrinter(OutputStream os)

StreamPrinter

public StreamPrinter()
Method Detail

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface StreamHandler

terminate

public void terminate()
Specified by:
terminate in interface StreamHandler

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

handleStream

public void handleStream(InputStream is)
Specified by:
handleStream in interface StreamHandler

getPrefix

public String getPrefix()

getOutputStream

public OutputStream getOutputStream()

isFinished

public boolean isFinished()
Specified by:
isFinished in interface StreamHandler

awaitFinish

public void awaitFinish()
Specified by:
awaitFinish in interface StreamHandler


Copyright © 2011. All Rights Reserved.