KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > gnupg > LineProcessors > StreamLineGobbler


1 package SnowMailClient.gnupg.LineProcessors;
2
3
4 import java.util.*;
5 import java.io.*;
6
7 public final class StreamLineGobbler extends Thread JavaDoc
8 {
9     private InputStream inputStream;
10     LineProcessor lineProcessor;
11
12
13    /**
14     * Constructor 1.
15     */

16     public StreamLineGobbler( final InputStream inputStream, LineProcessor lineProcessor)
17     {
18       this.inputStream = inputStream;
19       this.lineProcessor = lineProcessor;
20     }
21
22
23
24     public void run()
25     {
26       try
27        {
28          final InputStreamReader isr = new InputStreamReader(this.inputStream);
29          final BufferedReader br = new BufferedReader(isr);
30          String JavaDoc line = null;
31          while( (line = br.readLine()) != null)
32          {
33             lineProcessor.processLine( line );
34          }
35        }
36       catch( IOException ioe )
37        {
38          ioe.printStackTrace();
39        }
40     } //run
41

42
43
44 }
Popular Tags