Given a file and we have to read its content line by line using java program.
For this program, I am using a file named "B.txt" which is located at "E:\" drive, hence the path of the file is "E:\B.txt", and the content of the file is:
This is line 1
This is line 2
This is line 3
This is line 4
Program to read file line by line in java
Output