Code example for LineNumberReader

0
	private char peeked;
	private boolean peekWaiting = false;
	 
	public SourceFile(URL location) throws IOException {
		URL sourceLocation = location;
		lineReader = new LineNumberReader( new InputStreamReader( sourceLocation.openStream() ) );
 
	} 
	public SourceFile(String filename) throws IOException {
		File file = new File( filename );
		if( file.exists() && file.canRead() ) {
			FileInputStream read = new FileInputStream( file );
			lineReader = new LineNumberReader( new InputStreamReader( read ) );
		} else { 
			throw new IOException( "Cannot open file: " + filename);
		} 
	} 
	 
	public char getNextChar() { 
		if ( peekWaiting ) {
			peekWaiting = false;