can you not do something like this,

Scanner s = new Scanner(new FileReader("test.java")); // handle exceptions
while(s.hasNext()){
s.readLine(); // do something with this value...like search...