I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file<
I tested the above methods for counting lines and here are my observations for Different methods as tested on my system
File Size : 1.6 Gb Methods:
Moreover Java8 Approach seems quite handy :
Files.lines(Paths.get(filePath), Charset.defaultCharset()).count()
[Return type : long]