112 Program to read data from file in Java

Code:
import java.io.*;

class FISDemo

{

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

 {

  FileInputStream fis = new FileInputStream("abc.txt");



  int data = fis.read();



  while(data != -1)

  { 

   char c = (char) data;

   System.out.print(c);

   data = fis.read();

  }



  fis.close();

  }

}

Ouput:


read data from file in Java

Previous
Next Post »