作用:
利用内存空间 进行缓存 减少磁盘的读写速度
原理:
缓冲数组
底层采用 长度为 8192 的 byte[] 数组 存储数据
分类:
字节输入缓冲流 BufferedInputStream
字节输出缓冲流 BufferedOutputStream
创建:
字节输入缓冲流:
//节点流
InputStream is = new FileInputStream("C:/a.txt");
//处理流
BufferedInputStream bis = new BufferedIntputStream(is);
字节输出缓冲流:
//节点流
OutputStream os = new FileOutputStream("C:/a.txt");
//处理流
BufferedOutputStream bis = new BufferedOutputStream(is);
复制:
为了 提高 读取的速度
可创建一个 任意大的 byte[] bytes
数组,然后再
byte[] bytes = new byte[1024*200];
int len = 0;
while((len = bis.read(bytes)) != -1) {
bis.writer(bytes, 0, len);
}