集册 Java实例教程 读取文件输入流

读取文件输入流

欢马劈雪     最近更新时间:2020-01-02 10:19:05

385
读取文件输入流

import java.io.FileInputStream;
/*
 from 时代Java公众号 - N o w J a  v a . c o m 
*/

import java.io.IOException;


public class Main {

  public static void main(String[] arguments) {

    try (FileInputStream file = new FileInputStream("save.gif")) {

      boolean eof = false;

      int count = 0;

      while (!eof) {

        int input = file.read();

        System.out.print(input + " ");

        if (input == -1)
        /** 
         来自 NowJava.com - 时代Java**/

          eof = true;

        else

          count++;

      }

      file.close();

      System.out.println(
展开阅读全文