KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > browser > browsers > StreamConsumer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ui.internal.browser.browsers;
12
13 import java.io.*;
14
15 import org.eclipse.ui.internal.browser.WebBrowserUIPlugin;
16 /**
17  * Used to receive output from processes
18  */

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

46     public String JavaDoc getLastLine() {
47         return lastLine;
48     }
49 }
Popular Tags