org.opensubsystems.core.util
Class StreamGobbler

java.lang.Object
  extended by java.lang.Thread
      extended by org.opensubsystems.core.util.StreamGobbler
All Implemented Interfaces:
java.lang.Runnable

public class StreamGobbler
extends java.lang.Thread

Class to read or capture specified input stream. This class was insipred by article http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Version:
$Id: StreamGobbler.java,v 1.4 2007/01/07 06:14:00 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.2 2004/12/18 06:18:25 bastafidli

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  boolean m_bCapture
          If true then the stream will be captured (carefull about memory) and can be read.
protected  java.io.InputStream m_inputStream
          Input stream to read.
protected  long m_lMaxCaptureSize
          Maximal size of the stream to be held in memory.
protected  java.lang.StringBuffer m_sbStreamContent
          Content of the stream if it should be captured
protected  java.lang.String m_streamName
          Name of the stream.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamGobbler(java.io.InputStream is, java.lang.String name)
          Constructor.
StreamGobbler(java.io.InputStream is, java.lang.String name, boolean bCapture, long lMaxCaptureSize)
          Constructor
 
Method Summary
 java.lang.String getStreamContent()
           
 void run()
          
 
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, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_inputStream

protected java.io.InputStream m_inputStream
Input stream to read.


m_streamName

protected java.lang.String m_streamName
Name of the stream.


m_bCapture

protected boolean m_bCapture
If true then the stream will be captured (carefull about memory) and can be read.


m_lMaxCaptureSize

protected long m_lMaxCaptureSize
Maximal size of the stream to be held in memory.


m_sbStreamContent

protected java.lang.StringBuffer m_sbStreamContent
Content of the stream if it should be captured

Constructor Detail

StreamGobbler

public StreamGobbler(java.io.InputStream is,
                     java.lang.String name)
Constructor. The stream will not be captured.

Parameters:
is - - input stream to read or capture
name - - name of the stream

StreamGobbler

public StreamGobbler(java.io.InputStream is,
                     java.lang.String name,
                     boolean bCapture,
                     long lMaxCaptureSize)
Constructor

Parameters:
is - - input stream to read or capture
name - - name of the stream
bCapture - - if true then the stream will be captured (carefull about memory) and can be read
lMaxCaptureSize - - maximal size of the stream to be held in memory.
Method Detail

run

public void run()

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

getStreamContent

public java.lang.String getStreamContent()
Returns:
String - the content of the captured stream or null if you choose to do not capture it.


Copyright © 2003 - 2006 OpenSubsystems s.r.o.