I need this for a program that serches for a string within some text in a text file, and when it is found gives the location of the line, and column in which the text is located.
In that case you could also look into using java.io.LineNumberReader (which is a subclass of BufferedReader).
A basic algorithm would be:
- read each line of the file into a String
- compare String against criteria (String.indexOf("my_criteria"))
- if a match, record line number from LineNumberReader.getLineNumber(), and record position of match in String (indexOf)
James.