Solved programming problem

Read Data From .txt File with Buffered Reader in Java.

Source code

package reader;

import java.io.FileReader;

import java.io.IOException;

import java.io.BufferedReader;

public class Reader

{

    public static void main(String[] args)

    {

       BufferedReader reader = null;

       try

       {

           reader  = new BufferedReader(new FileReader("input.txt"));///open file

     

           String c;

           while((c=reader.readLine())!=null) ///read the file until empty

           {

               System.out.println(c);

           }

         

       }

       catch(IOException e)

       {

           System.out.println("File Does Not Open");

       }

     

    }

 

}

Output

.txt File

 

 

 

 

 

code

to

haven

Join the discussion

Add your comment