number of lines in a file

Number of Lines in File

Sometimes, in coding, it is required to know the number of lines existing in a file programmatically. There is no direct way (a predefined method) to find out in Java. To do the job, the help of BufferedReader's readLine() method is taken. While reading each line, the counter is incremented;…

LineNumberReader Java

The character stream LineNumberReader is equivalent to LineNumberInputStream on byte streams side. Being a subclass of BufferedReader, it can make use of all the methods of BufferedReader like readLine() to read a line. getLineNumber() method of this class can be used to give line numbers. Following is the class signature…