JAVA Program to Read Data Byte by Byte from File

JAVA Program to Read Data Byte by Byte from File:

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

   fr=new FileInputStream(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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.