Java FileInputStream read ASCII text file

Description

Java FileInputStream read ASCII text file


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

public class Main {
  public static void main(String args[]) {
    int i;//  w w w .  ja  v a  2s  . c  o m
    try (FileInputStream fin = new FileInputStream("Main.java")) {
      do {
        i = fin.read();
        if (i != -1)
          System.out.print((char) i);
      } while (i != -1);
      fin.close();
    } catch (IOException e) {
      System.out.println("An I/O Error Occurred");
    }
  }
}



PreviousNext

Related