package com.sf._03_字节输入流;

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

public class Test1 {
    public static void main(String[] args) throws IOException {
        //1 字节输入流
        FileInputStream fileInputStream = new FileInputStream(new File("D:\\a.txt"));

        byte[] buffer = new byte[4];
        int readLen = fileInputStream.read(buffer);
        System.out.println("读取长度为:"+readLen);   // 4
        System.out.println("读取内容为:"+ new String(buffer,0,readLen));  //fanj
        if(readLen !=-1){
            int readLen1 = fileInputStream.read(buffer);
            System.out.println("读取长度为:"+readLen1);  // 4
            System.out.println("读取内容为:"+ new String(buffer,0,readLen1)); //ialo

            if(readLen1!=-1){
                int readLen2 = fileInputStream.read(buffer);
                System.out.println("读取长度为:"+readLen2); //4
                System.out.println("读取内容为:"+ new String(buffer,0,readLen2));  //ngha

                if(readLen2!=-1){
                    int readLen3 = fileInputStream.read(buffer);
                    System.out.println("读取长度为:"+readLen3); //2
                    System.out.println("读取内容为:"+ new String(buffer,0,readLen3));  //ha
                }else{
                    System.out.println("已读完");
                }
            }else{
                System.out.println("已经读取完毕");
            }

        }else{
            System.out.println("已经读取完毕");
        }



    }
}
