The Java language provides a lot og useful classes to handle files, the LineNumberReader class is one of them.

In the following method I'm using the LineNumberReader to retrieve the length of a text file in terms on number of lines.



To use this method you have to pass to it the path to the text file you want to analyze, and you'll get the number of lines contained in it.