Java Examples
Java ExamplesPrograms with output

Java Program to Read File using BufferedReader


Example:
import java.io.*;
 
public class ReadFile {
   public static void main(String[] args)  {
      try {
         BufferedReader in = new BufferedReader(new FileReader("c:\\filename.txt"));
         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 ***

Share this page on:

Was this page helpful ?

Let us know how we did!

Subscribe Email Updates

to get latest update