I understand the theory behind BufferedOutputStream . Bytes are written to the buffer array until it is full, and then written (flushed) to the base stream - the idea is that it is faster than writing bytes, since there are fewer OS calls.
However, looking at the implementation of the BufferedOutputStream class and methods ( BufferedOutputStream.java ), it seems that ultimately the bytes from the buffer are written only bytes.
I think this is so because:
In BufferedOutputStream.write (byte b [], int off, int len) has the string out.write (b, off, len). Since out is an instance of OutputStream but not a BufferedOutputStream, it calls OutputStream.write (byte [], int, int). This in turn uses a for loop to write bytes by bytes
Please, can someone clarify what is actually happening, and how is this faster?
source share