KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jdiff > StreamReader


1 package jdiff;
2
3 import java.util.*;
4 import java.io.*;
5
6 /**
7  * Reads in lines from an input stream and displays them.
8  *
9  * See the file LICENSE.txt for copyright details.
10  * @author Matthew Doar, doar@pobox.com.
11  */

12 class StreamReader extends Thread JavaDoc {
13     /** The input stream. */
14     InputStream is_;
15         
16     /** Constructor which takes an InputStream. */
17     StreamReader(InputStream is) {
18         is_ = is;
19     }
20         
21     /** Method which is called when this thread is started. */
22     public void run() {
23         try {
24             InputStreamReader isr = new InputStreamReader(is_);
25             BufferedReader br = new BufferedReader(isr);
26             String JavaDoc line = null;
27             while((line = br.readLine()) != null)
28                 System.out.println(line);
29         } catch (IOException ioe) {
30             System.out.println("IO Error invoking Javadoc");
31             ioe.printStackTrace();
32         } catch (Exception JavaDoc e) {
33             // Ignore read errors which indicate that the process is complete
34
}
35     }
36 }
37
Popular Tags