Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding line number of a word in a text file using java

I require searching a word in a text file and display the line number using java. If it appears more than once I need to show all the line numbers in the output. Can anyone help me please?

like image 349
Neel Avatar asked Jan 18 '26 20:01

Neel


1 Answers

Read the text file using Java class LineNumberReader and call method getLineNumber to find the current line number.

http://docs.oracle.com/javase/7/docs/api/java/io/LineNumberReader.html

like image 80
Simon C Avatar answered Jan 20 '26 10:01

Simon C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!