imho ReadBuffer/WriteBuffer are over-engineered. They appear to be
implemented to code around potential bugs (or perhaps an idiosyncrasy) in a
If I ask a stream to read/write N bytes then that is what the stream should
do. If it needs to break the request into smaller "chunks" to satisfy the
request then that should be transparent to the consumer code.
I would call this "chunking" rather than "buffered". Buffered read/write
I/IO typically works on blocks LARGER than the individual requests, not
smaller. i.e. you ask to read 4 bytes but a larger buffer of (e.g.) 1KB is
read so that future requests can be satisfied from the buffer, and asking
to write 4 bytes just stuffs a buffer which is only *actually* written when
then buffer is full, both designed to minimise I/O.