All pastes #210778 Raw Edit

Find.java

public java v1 · immutable
#210778 ·published 2006-10-20 00:09 UTC
rendered paste body
/** *Class Name: Find *---------------- *Version: 0.1 *---------------- *Written by: Aaron Cripps * *Purpose: *-------- *To implement a class that searches a file for a given string ... this program is responsible only for  *searching the file for the keyword substring, although with a program of this type there is much more  *functionality available, like that of the UNIX tool, and the GNU clone, grep. * */import java.io.FileNotFoundException;public class Find{	private static final boolean DEBUG = true;	public static void main(String[] args){		int count = 0;		JGrep jgrep = null;		for(int i=1; i<args.length;i++){			try{			jgrep = new JGrep(args[i]);			}			catch(FileNotFoundException e){				System.out.println("File Not Found.");					break;			}			count = 0;						while(jgrep.getLine() != null){				count += 1;				if(jgrep.searchLine(args[0])){					System.out.println("Line " +count + ": " + jgrep.getMatchedLine(args[0]));				}//end of if				if(DEBUG)System.out.println("count = " +count);			}//end of while			jgrep.closeScanner();			if(DEBUG)System.out.println("iterations = " + (i-1));		}//end of for		if(DEBUG)System.out.println("Main method finished executing.Program will now exit.");	}//end of main}//end of file