Описание тега bufferedinputstream
An BufferedInputStream
is a wrapper around an InputStream
, whereby the data being read is buffered locally. Buffering can be either fully-buffered or partially-buffered. Fully-buffered is where the entire contents of the InputStream
is held locally in a variable. Partially-buffered is where a small portion of the stream data is held in a local variable, and as you read data from the buffer, those bytes are replaced with the next X bytes from the stream - ie the buffer overwrites itself as the data is consumed from it.
An InputStream
is usually buffered to improve performance, as it allows data to be read from a network of file in large efficient chunks, rather than a number of smaller reads. This removes the overhead and performance impact of the multiple small reads. The downside, however, is that the buffer consumes some memory and has some CPU impact, but these downsides are usually very tiny, and are far outweighed by the benefits of buffering.