JAVA Program to Read Data Character by Character from File

JAVA Program to Read Data Character by Character from File:


import java.io.*;
class file3
{
 public static void main(String args[])
 {
   File f=new File("abc.txt");
   FileReader fr=null;
  try
  {

   fr=new FileReader(f);
   int ch;
   while((ch=fr.read())!=-1)
   {
    System.out.print((char)ch);
   }
  }
  catch(Exception e){}

  finally
  {
      try
      {
   fr.close();
}
catch(Exception e){}
  }
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

seventeen − 15 =