001package com.thed.launcher; 002 003import java.io.IOException; 004import java.io.InputStream; 005 006public class InputStreamHandler 007 extends Thread 008{ 009 /** 010 * Stream being read 011 */ 012 013 private InputStream m_stream; 014 015 /** 016 * The StringBuffer holding the captured output 017 */ 018 019 private StringBuffer m_captureBuffer; 020 021 /** 022 * Constructor. 023 * 024 * @param 025 */ 026 027 public InputStreamHandler( StringBuffer captureBuffer, InputStream stream ) 028 { 029 m_stream = stream; 030 m_captureBuffer = captureBuffer; 031 start(); 032 } 033 034 /** 035 * Stream the data. 036 */ 037 038 public void run() 039 { 040 try 041 { 042 int nextChar; 043 while( (nextChar = m_stream.read()) != -1 ) 044 { 045 m_captureBuffer.append((char)nextChar); 046 } 047 } 048 catch( IOException ioe ) 049 { 050 } 051 } 052}