Reading a [.txt] File in Java

 By Anshuman Pattnaik

Note: this is related to the writing in txt file program , found at click


 CODING 

import java.io.*;

class File2

{

    public static void main(String args[])throws IOException

    {

        FileReader fr= new FileReader ("Names.txt");

        BufferedReader br = new BufferedReader(fr);

        String nm;

        while((nm=br.readLine())!=null)

        {

             System.out.println(nm);

        }

        br.close();

    }

}

 RESULT:




Post a Comment

0 Comments