01: package org.enhydra.kelp.ant;
02:
03: import java.io.BufferedReader;
04: import org.enhydra.kelp.common.AbstractEchoBuilder;
05: import java.io.PrintWriter;
06:
07: /**
08: * This thread used for read error messages from executing process
09: */
10: public class ErrorReader extends Thread {
11: BufferedReader er;
12: AbstractEchoBuilder aeg;
13: PrintWriter log;
14:
15: public ErrorReader(BufferedReader bufferedreader,
16: AbstractEchoBuilder aEcho, PrintWriter logWriter) {
17: aeg = aEcho;
18: er = bufferedreader;
19: log = logWriter;
20: }
21:
22: public void run() {
23: try {
24: for (; !er.ready(); Thread.sleep(100L)) {
25: }
26: String s;
27: while ((s = er.readLine()) != null) {
28: aeg.getEchoWriter().println(s);
29: if (log != null) {
30: log.println(s);
31: }
32: }
33: } catch (Exception exception) {
34: }
35: }
36: }
|