package com.czie.iot1913.lps.IO.InPutStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
/**
 * FileName: FileInputStreamTest01
 * Author:   lps
 * Date:     2022/3/23 21:17
 * Sign:刘品水 Q:1944900433
 */
public class FileInputStreamTest01 {
    public static void main(String[] args) throws IOException {
       //创建字节输入流对象
        FileInputStream fis = new FileInputStream("F:\\JavaCode\\fos.txt");
        //调用字节输入流对象读数据的方法
       /* //第一次读取数据
        int by = fis.read();
        System.out.println(by);
        System.out.println((char) by);
        //第二次读取数据
        by = fis.read();
        System.out.println(by);
        System.out.println((char) by);
        //在多读取两次
        by = fis.read();
        System.out.println(by);
        System.out.println((char) by);*/
       /* int by=fis.read();
        while (by!=-1){
            System.out.print((char)by);
            by=fis.read();by = fis.read()
        }*/
        //优化上面的程序
        int by;
        while ((by = fis.read())!=-1){
            System.out.print((char)by);
        }
        //释放资源
        fis.close();
    }
}
![]()