KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ServiceDaemonReadThread


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 /* @version $Id: ServiceDaemonReadThread.java 155409 2005-02-26 12:57:06Z dirkv $ */
18 import java.io.InputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.lang.Thread JavaDoc;
21 import java.io.BufferedReader JavaDoc;
22 import java.io.InputStreamReader JavaDoc;
23
24 public class ServiceDaemonReadThread extends Thread JavaDoc {
25     private BufferedReader JavaDoc in;
26     ServiceDaemonReadThread(InputStream JavaDoc in) {
27             this.in = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(in));
28         }
29     public void run() {
30         String JavaDoc buff;
31         for (;;) {
32             try {
33                 buff = in.readLine();
34                 if (buff == null) break;
35                 System.err.print(in.readLine());
36             } catch (IOException JavaDoc ex) {
37                 break; // Exit thread.
38
}
39         }
40     }
41 }
42
Popular Tags