KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > ant > ErrorReader


1 package org.enhydra.kelp.ant;
2
3 import java.io.BufferedReader JavaDoc;
4 import java.io.PrintStream JavaDoc;
5 import org.enhydra.kelp.common.AbstractEchoBuilder;
6 import java.io.PrintWriter JavaDoc;
7
8 /**
9  * This thread used for read error messages from executing process
10  */

11 public class ErrorReader extends Thread JavaDoc {
12     BufferedReader JavaDoc er;
13     AbstractEchoBuilder aeg ;
14     PrintWriter JavaDoc log;
15     public ErrorReader(BufferedReader JavaDoc bufferedreader, AbstractEchoBuilder aEcho, PrintWriter JavaDoc logWriter) {
16         aeg = aEcho;
17         er = bufferedreader;
18         log = logWriter;
19     }
20
21     public void run() {
22         try {
23             for(; !er.ready(); Thread.sleep(100L)) { }
24             String JavaDoc s;
25             while((s = er.readLine()) != null) {
26                 aeg.getEchoWriter().println(s);
27                 if(log != null){
28                     log.println(s);
29                 }
30             }
31         }
32         catch(Exception JavaDoc exception) { }
33     }
34 }
Popular Tags