[英]Does FileInputStream have an internal buffer
This question includes the following surpising (to me) assertion 这个问题包括以下令人惊讶的(对我而言)断言
both Java and Perl try quite hard to find a one-size-fits all default buffer size when reading in files
在读取文件时,Java和Perl都很难找到一个适合所有默认缓冲区大小
The Javadoc for FileInputStream
however makes no mention of the class having its own buffer. 然而,
FileInputStream
的Javadoc没有提到具有自己的缓冲区的类。 And why should it, given that there is a BufferedInputStream
class? 既然有一个
BufferedInputStream
类,它为什么要这样呢? Do objects of class FileInputStream
have their own buffer? 类
FileInputStream
对象有自己的缓冲区吗? I realize that the O/S itself will have buffers; 我意识到O / S本身会有缓冲区; I'm not asking about those.
我不是在问这些问题。
It doesn't, at least in OpenJDK. 它至少在OpenJDK中没有。
However, I don't see anything in its contract that would forbid the existence of such a buffer, as long as it was transparent to the user. 但是,我没有在合同中看到任何禁止存在这种缓冲区的内容,只要它对用户是透明的。 It would not make much sense, though, given that
BufferedInputStream
exists for that purpose. 但是,考虑到为此目的存在
BufferedInputStream
,这没有多大意义。
The SO question you mention deals specifically with InputStreamReader
and BufferedReader
instead of *Stream classes you talk about. 你提到的SO问题专门用于处理
InputStreamReader
和BufferedReader
而不是你所谈论的* Stream类。 It even mentions the default buffer size of BufferedReader. 它甚至提到了BufferedReader的默认缓冲区大小。
I know it is a long post, but you should read it all instead of forking it to another question after reading its first sentence. 我知道这是一个很长的帖子,但你应该阅读所有内容,而不是在阅读完第一句话之后将其分解为另一个问题。
To give you an answer, looking at the link provided by Matt Ball , apparently not . 为了给你答案,看看Matt Ball提供的链接,显然不是 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.