BufferedInputStream/BufferedOutputStream

BufferedInputStream/BufferedOutputStream
缓冲流
提供内存缓冲数组
用来提高单字节的读写效率

public class BufferedReader extends Reader {
 private char cb[];
 private static int defaultCharBufferSize = 8192;
}

FIS文件输入流


BufferedInputStream

BufferedInputStream

FOS文件输出流


BufferedOutputStream

BufferedOutputStream
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestBuffered {
    public static void main(String[] args) throws IOException {
        /**
         * BOS-->FOS-->f5
         */
        
        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("f5"));
        out.write(97);
        out.write(98);
        out.write(99);
        out.flush();//刷出缓存数据
        //高级流close()
        //1.flush()2.关闭相接的流
        System.out.println("写入完成!");
        out.close();
    }
}

运行结果

写入完成!

文件f5的内容

abc

你可能感兴趣的:(BufferedInputStream/BufferedOutputStream)