KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > browser > StreamConsumer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.browser;
12
13 import java.io.*;
14
15 import org.eclipse.help.internal.base.*;
16
17 /**
18  * Used to receive output from processes
19  */

20 public class StreamConsumer extends Thread JavaDoc {
21     BufferedReader bReader;
22
23     private String JavaDoc lastLine;
24
25     public StreamConsumer(InputStream inputStream) {
26         super();
27         setDaemon(true);
28         bReader = new BufferedReader(new InputStreamReader(inputStream));
29     }
30
31     public void run() {
32         try {
33             String JavaDoc line;
34             while (null != (line = bReader.readLine())) {
35                 lastLine = line;
36                 BrowserLog.log(line);
37             }
38             bReader.close();
39         } catch (IOException ioe) {
40             HelpBasePlugin.logError(
41                     "Exception occurred reading from web browser.", ioe); //$NON-NLS-1$
42
}
43     }
44
45     /**
46      * @return last line obtained or null
47      */

48     public String JavaDoc getLastLine() {
49         return lastLine;
50     }
51
52 }
53
Popular Tags