Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program in java to read data from disk file

Write a program in java to read data from disk file

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

public class BufferedReaderExample {

            public static void main(String[] args) {

                        BufferedReader br = null;

                        try {

                                    String sCurrentLine;

                                    br = new BufferedReader(new FileReader("D:\\readdata.txt"));

                                    while ((sCurrentLine = br.readLine()) != null) {
                                                System.out.println(sCurrentLine);
                                    }

                        } catch (IOException e) {
                                    e.printStackTrace();
                        } finally {
                                    try {
                                                if (br != null)br.close();
                                    } catch (IOException ex) {
                                                ex.printStackTrace();
                                    }
                        }

            }
}
Previous
Next Post »