Java FileInputStream read int from file

Description

Java FileInputStream read int from file

import java.io.FileInputStream;
import java.io.IOException;

public class Main {
  public static void main(String[] args) {

    try (FileInputStream fin = new FileInputStream("Main.java")) {
      int data;/*w ww.  j av  a 2 s . co m*/
      while ((data = fin.read()) != -1) {
        System.out.print(data);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}



PreviousNext

Related