0

The below line is from the java documentation.

"Buffered input streams read data from a memory area known as a buffer; the native input API is called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full."

Can some-one explain what does the line mean especially the last part of it ..

azro
  • 53,056
  • 7
  • 34
  • 70
  • Why we use that is clear but couldn't understand this part of the sentence : "Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full." – Leveling_up Dec 31 '22 at 11:24
  • Your data is written into a buffer in memory. It is only written to native output (which might be hard drive, network io, etc.) when the buffer is full. Usually, you can call `flush` to force the data to be written to the output before the buffer getting filled. – Ervin Szilagyi Dec 31 '22 at 11:24
  • "Only if the buffer is full then the data will be written" thanks @Ervin Szilagyi understood that but what if we don't flush the partially-filled buffer ? – Leveling_up Dec 31 '22 at 11:26
  • Depending on your system, the data might get simply lost. – Ervin Szilagyi Dec 31 '22 at 11:28

0 Answers0