【FileInputStream类:字节输入流】

package test;

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

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/11/9 16:16
 */
public class FileInputStreamDemo1 {
    /*
     *字节输入流操作步骤:
     *A:创建字节输入流对象
     *B:调用read()方法读取数据,并把数据显示在控制台
     *C:释放资源
     *
     *读取数据的方式:
     *A:int read():一次只能读一个字节
     *B: int read(byte[] b):一次读取一个字节数组
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("fos.txt");
        int by = 0;
        while((by=fis.read())!=-1){
            /**不能识别汉字*/
            System.out.println((char)by);
        }
    }

}
终身学习者
原文地址:https://www.cnblogs.com/zuixinxian/p/9941131.html