Java

Java - Read the Text File

Java - Read the Text File
// Read the File



import java.io.*;

public class test9a

 {

  public static void main(String arg[])

     {

       try

        {

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

          BufferedReader br = new BufferedReader(fr); 

          String str;

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

             {  

                System.out.println("\n"+str+"\n");    

              }

         br.close();          

         fr.close();

          }

         catch(Exception e)

         { 

             System.out.println("Error...");           

         }

       }

   }
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.