Code: Select all
try {
this.curSearchString = this.in.readLine ();
while (true) {
if (this.curSearchString == null) {
// if there is a blank line, skip the search string
continue;
} // end if
// ...
curLine++;
curSearchString = this.in.readLine ();
} // end while
} catch (EOFException eof) {
// end-of-file reached
// do nothing
} catch (IOException e) {
System.err.println ("Error (MyGrep.search) : " + e.toString ());
e.printStackTrace ();
} // end try-catch block
For some reason, it's looping infinitely despite an 18 line input file. It worked without the end of file check, but that was before I was told that blanklines are fair game for this assignment.
this.in is a BufferedReader (FileReader) object.
Any help is appreciated.