Java Program to Read File using BufferedReader


-

-

Example:

Copied
import java.io.*;
 
public class ReadFile {
   public static void main(String[] args)  {
      try {
         BufferedReader in = new BufferedReader(new FileReader("c:\\filename"));
         String str;
         while ((str = in.readLine()) != null) {
            System.out.println(str);
         }
         System.out.println(str);
         }
      catch (IOException e) {
      }
    }
}

Output:

*** this is content of the File ***