字节缓冲流

点击查看代码
package it_04;

import java.io.*;

public class Demo4 {
    public static void main(String[] args) throws IOException {
//        FileOutputStream fos = new FileOutputStream("bos.txt");
//        BufferedOutputStream bos =new BufferedOutputStream(fos);
//        bos.write("hello\n".getBytes());
//        bos.write("world\n".getBytes());
        FileInputStream fis =new FileInputStream("bos.txt");
        BufferedInputStream bis = new BufferedInputStream(fis);
//        int read;
//        while((read= bis.read())!=-1){
//            System.out.print((char)read);
//        }
        byte[] by =new byte[1024];
        int len;
        while((len=bis.read(by))!=-1){
            System.out.println(new String(by,0,len));
        }
        bis.close();
    }
}

posted @ 2025-04-22 16:21  lfqyj  阅读(5)  评论(0)    收藏  举报