1 package org.codehaus.groovy.syntax.lexer; 2 3 import java.io.InputStream ; 4 import java.io.IOException ; 5 import org.codehaus.groovy.syntax.ReadException; 6 7 public class InputStreamCharStream 8 extends AbstractCharStream 9 { 10 private InputStream in; 11 12 public InputStreamCharStream(InputStream in) 13 { 14 this.in = in; 15 } 16 17 public InputStreamCharStream(InputStream in, 18 String description) 19 { 20 super( description ); 21 this.in = in; 22 } 23 24 public InputStream 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 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 e ) 50 { 51 throw new ReadException( e ); 52 } 53 } 54 } 55 | Popular Tags |