KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > wizard > ErrorReader


1 /*
2 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
3
4
5     Copyright (C) 2003 Together
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public
9     License as published by the Free Software Foundation; either
10     version 2.1 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     Lesser General Public License for more details.
16
17     You should have received a copy of the GNU Lesser General Public
18     License along with this library; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */

21
22 package org.webdocwf.util.loader.wizard;
23
24 import java.io.BufferedReader JavaDoc;
25 import java.io.PrintStream JavaDoc;
26 import java.io.IOException JavaDoc;
27
28
29 /**
30  * This thread is used for reading error messages occured while executing process.
31  */

32 public class ErrorReader extends Thread JavaDoc {
33     BufferedReader JavaDoc er;
34     boolean trace = false;
35     /**
36      * Constructor.
37      *
38      * @param bufferedReader buffer reading that reads error messages.
39      */

40     public ErrorReader(BufferedReader JavaDoc bufferedReader) {
41         er = bufferedReader;
42     }
43
44     /**
45      * Constructor.
46      *
47      * @param bufferedReader buffer reading that reads error messages.
48      * @param trace shows error messages trace.
49      */

50     public ErrorReader(BufferedReader JavaDoc bufferedReader, boolean trace) {
51         er = bufferedReader;
52         this.trace = trace;
53     }
54
55     /**
56      * Run the thread
57      */

58     public void run() {
59         try {
60             for(; !er.ready(); Thread.sleep(100L)) { }
61             String JavaDoc s;
62             while((s = er.readLine()) != null) {
63                 if (trace)
64                     System.out.println(s+"\n");
65             }
66         } catch (IOException JavaDoc e) {
67         } catch (InterruptedException JavaDoc e) {
68         }
69     }
70 }
71
Popular Tags