java program to read data from notepad file, using FileReader, BufferedReader

The below program is a very simple java code, to read line by line from text / notepad file

import java.io.BufferedReader;
import java.io.FileReader;

public class txt_read
{
    public static void main(String[] args) throws Exception
    {
     String str;   
     FileReader fr=new FileReader("e:\\sel-online\\data.txt");
     BufferedReader br=new BufferedReader(fr);
      ///read line from the file upto null    
     while((str=br.readLine())!=null)
     {
         System.out.println(str);
      }
     br.close();
    }
}

Refer : www.venkatgnselenium.blogspot.in
 

Comments