In Java and C #, there are several classes for buffering streams: BufferedStream in C #, Buffered(Input|Output)Stream and Buffered(Reader|Writer) .
They get some thread in the constructor and implement the same interface.
The question is, how does it work?
What happens when I try to read one byte? Does it read many bytes into the internal buffer and then return it in bytes after the byte? Writing a single byte? Writes to the internal buffer and writes to flush() to the internal stream?
And about reading / writing an array of bytes - is it inefficient to do this on buffered streams, which causes double copying of bytes to and from the internal array?
java c # stream encapsulation buffer
VorobeY1326
source share