S
S
Stepan2016-11-03 19:40:14
Programming
Stepan, 2016-11-03 19:40:14

What does buffered mean?

For example, Java has a BufferedReader or BufferedImage class. C++ has the cout.flush() function, which, as the documentation says, "flushes the buffer". What does it mean?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2016-11-03
@KonstantinovS

FOR I/O: It reads information in large chunks and stores those chunks in memory.
It serves to speed up access, if at the very highest level the file needs to be read one byte or character at a time, and at the very lowest level (for example, a hard disk), it is more efficient to do this in 4K blocks.
For readers, flush (if there is one; BufferedReader, for example, does not have it) is used for real-time streams: keyboard, communication ports, and so on. Everything that has accumulated in the buffer is discarded, and it is considered that at the moment T the stream is empty.
Writers, of course, do not write data immediately, but when the buffer is full, and a program crash or a power outage will destroy this data. For them, the flush command physically writes the accumulated data.
FOR PICTURES: The picture is not stored in a "hardware-efficient" form, but in such a way that the user can relatively easily change it.

A
abcd0x00, 2016-11-04
@abcd0x00

C++ has the cout.flush() function, which, as the documentation says, "flushes the buffer". What does it mean?

This means that the output to the screen is too expensive to perform for each character in turn. Therefore, characters are written to a buffer (an array in RAM), and then this buffer is displayed once on the screen. It's called "buffered output".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question