In Java and C# there are several classes for buffering streams:
BufferedStream
in C#, Buffered(Input|Output)Stream
and Buffered(Reader|Writer)
.
They gets some stream in constructor and implements the same interface.
The question is - how it works?
What happens, when I'm trying to read one byte? It reads a lot of bytes into inner buffer and then returns it to me byte after byte? On writing one byte? Writes into inner buffer and on flush()
writes it to inner stream?
And about reading/writing an array of bytes - is it inefficient to do it on buffered streams cause of double copying bytes into and from inner array?