Image may be NSFW.
Clik here to view.It's easy to simple count the lines in a file using Unix commands like
grep filename | wc -l
This would return you the number of lines in the file. However if you have to know that programmatically using Java API it is easy too.
All you have to do is to get a handle to the file stream and then in a loop scan through all the lines in the file. For this you can read the lines in the file using the readLine() method, as each line in the file would be separated by a newline character (\n) . As you do, increment the lines counter by 1. Finally close the file stream and you would get your answer i.e. the number of lines in the file.