带缓冲读写操作,“桶”的概念在哪体现?
//带缓冲字节流读取
BufferedInputStream bis=new BufferedInputStream(new FileInputStream(srcFile));
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(destFile));
int c;
while((c=bis.read())!=-1){
bos.write(c);
bos.flush();
//不带缓冲的字节流读取
FileInputStream in=new FileInputStream(srcFile);
FileOutputStream out=new FileOutputStream(destFile);
int c;
while((c=in.read())!=-1){
out.write(c);
out.flush();
}
//具体读写操作时,read()方法返回的都是读取到的字节,write写入的也是读到的字节内容,为什么前者(带缓冲)比(不带缓冲)快?前者“桶”的概念在哪体现?盼快速回复,谢谢!