IO system buffering is at a different level than Buffered * putStream.
Each call FileOutputStream.write(...)invokes a native method call (which is usually more expensive than an internal java call), and then switches the context to the OS kernel for the actual record. Even if the kernel (or the file system driver or the hard disk or the hard disk itself) performs more buffering, these costs will occur.
By wrapping the BufferedOutputStream around this, we will call our own recording method much less frequently, thereby providing much higher throughput.
(The same applies to other types of I / O, of course, I just used FileOutputStream as an example.)
source
share