Showing posts with label buffered reader. Show all posts
Showing posts with label buffered reader. Show all posts

Wednesday, 11 February 2015

Read File LIne By Line In Java

 In this program we read a file line by line using buffered reader

package filles;
import interview_set1.fileRead;

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

public class ReadFiles {
public static void main(String[] args) {
    String path="D:\\a\\hi.txt";
    BufferedReader br=null;
    try {
        FileReader fr=new FileReader(path);
        br=new BufferedReader(fr);
        String line;
        while ((line=br.readLine())!=null) {
            System.out.println(line);
        }
       
    } catch (Exception e) {
        System.out.println(e);
    }
}
}