Java BufferedInputStream read until end of file

Description

Java BufferedInputStream read until end of file


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

public class Main {

  public static void main(String[] args) throws Exception {
    File file = new File("Main.java");
    FileInputStream fin = new FileInputStream(file);

    BufferedInputStream bin = new BufferedInputStream(fin);
    while (bin.available() > 0) {
      System.out.println((char) bin.read());
    }/*from   w  ww  .j  a  v  a 2  s.co m*/
    bin.close();
  }
}



PreviousNext

Related