posted 8 years ago
You'll need to know what flush() does and what "flushing" means.
Some I/O classes use buffers to make I/O more efficient. If you write a single byte to an output stream, it's not immediately written to the file, network or wherever the output stream is writing to. It's stored in a buffer instead. When enough bytes have been written, the whole buffer is written at once. Writing a whole block of data at once to for example a harddisk is much more efficient (much faster) than writing byte by byte.
The flush() method forces the output stream to write whatever is in the buffer, even if the buffer is not yet full.
This mechanism is used for the console too. If you write just one character, it will be buffered, and not be displayed until you either flush the output stream or write a newline character. (PrintStream, which is what System.out is, detects newline characters and automatically flushes its buffer when it sees one).