Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > System.out.flush()

Thread Tools


Posts: n/a
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.
Reply With Quote
Chris Smith
Posts: n/a
Batman4050 wrote:
> 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.

The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off