KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > groovy > syntax > lexer > InputStreamCharStream


1 package org.codehaus.groovy.syntax.lexer;
2
3 import java.io.InputStream JavaDoc;
4 import java.io.IOException JavaDoc;
5 import org.codehaus.groovy.syntax.ReadException;
6
7 public class InputStreamCharStream
8     extends AbstractCharStream
9 {
10     private InputStream JavaDoc in;
11
12     public InputStreamCharStream(InputStream JavaDoc in)
13     {
14         this.in = in;
15     }
16
17     public InputStreamCharStream(InputStream JavaDoc in,
18                                  String JavaDoc description)
19     {
20         super( description );
21         this.in = in;
22     }
23
24     public InputStream JavaDoc getInputStream()
25     {
26         return in;
27     }
28
29     public char consume()
30         throws ReadException
31     {
32         try
33         {
34             return (char) getInputStream().read();
35         }
36         catch( IOException JavaDoc e )
37         {
38            throw new ReadException( e );
39         }
40     }
41
42     public void close()
43         throws ReadException
44     {
45         try
46         {
47             getInputStream().close();
48         }
49         catch( IOException JavaDoc e )
50         {
51             throw new ReadException( e );
52         }
53     }
54 }
55
Popular Tags