System.out.flush()

Discussion in 'Java' started by Batman4050, Sep 26, 2004.

  1. Batman4050

    Batman4050 Guest

    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
    Batman4050, Sep 26, 2004
    #1
    1. Advertising

  2. Batman4050

    Chris Smith Guest

    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.

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

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Sep 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,327
    Steve
    Jul 1, 2003
  2. Rhino
    Replies:
    0
    Views:
    1,638
    Rhino
    Nov 13, 2004
  3. JGH
    Replies:
    2
    Views:
    6,957
    Malte
    Feb 23, 2005
  4. spidey12345
    Replies:
    2
    Views:
    400
    spidey12345
    Feb 8, 2007
  5. ash
    Replies:
    1
    Views:
    1,739
    Janusch
    Mar 25, 2008
Loading...

Share This Page