I'm using scanner to read a text file line by line but then how to get line number since scanner iterates through each input?My program is something like this:
s = new Scanner(new BufferedReader(new FileReader("input.txt")));
while (s.hasNext()) {
System.out.print(s.next());
This works fine but for example:
1,2,3 3,4,5
I want to know line number of it which mean 1,2,3 is in line 1 and 3,4,5 is in line 2.How do I get that?