Tutorialspoint examples

Learn java tutorial with examples for beginners online

read file content line by line java program

The readLine() method is used to get file content line by line. The readLine() returns one line at each iteration.


package com.tutorialspointexamples;
import java.io.BufferedReader;
import java.io.FileReader;
public class ReadFile {
  public static void main(String args[]){
	 String fileName = "D:/Test files/file 3.txt";
	 BufferedReader br = null;
     String strLine = "";
     try {
         br = new BufferedReader( new FileReader(fileName));
         while( (strLine = br.readLine()) != null){
     } catch (Exception e) {


Content file 3

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status