System.out.flush()

B

Batman4050

Does the line System.out.flush(); do anything?

I have added it to many of my programs, and I can't find any
difference with using it?

Does anyone know it's intended use, and why it's needed?

Thank you very much. :D
 
C

Chris Smith

Batman4050 said:
Does the line System.out.flush(); do anything?

Of course. It causes everything that's been written to System.out to be
completely written. System.out can do some internal buffering of data,
so you aren't guaranteed that something written to the stream will
appear immediately in the standard output of the process... unless you
call flush().

However, System.out is generally set up with auto-flush, so that you
only need to worry about this if you write something less than complete
lines at a time.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top