缓冲与非缓冲,使用哪个? [英] Buffered vs non buffered, which one to use?

查看:94
本文介绍了缓冲与非缓冲,使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这是重复的,但我无法找到每种类型的最佳实践的明确答案.

I am sorry if this is a duplicate but I was not able to find a definitive answer to what is the best practice for each type.

我想知道什么条件定义了何时使用BufferedReader与FileReader或BufferedInput/OutputStream与FileInput/OutputStream?有没有一种公式可以始终告诉您什么是合适的?

I would like to know what the appropriate conditions are that define when to use BufferedReader vs FileReader or BufferedInput/OutputStream vs FileInput/OutputStream? Is there a formula of sorts that will always tell you what is appropriate?

我应该一直使用缓冲吗?

Should I just always used buffered?

谢谢

推荐答案

如果流将具有许多小的访问权限,请使用缓冲区.如果要访问的访问量相对较少,相对较大,请使用无缓冲.

Use a buffer if the stream is going to have lots of small access. Use unbuffered if you are going to have relatively few, relatively large accesses.

这篇关于缓冲与非缓冲,使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆