Topic: 谁能解释一下System.out.flush()的作用

  Print this page

1.谁能解释一下System.out.flush()的作用 Copy to clipboard
Posted by: zwj0231075
Posted on: 2006-01-02 10:51

谁能帮我解释一下System.out.flush()的作用,可以给出一个简单的实例吗??
谢谢!!

2.Re:谁能解释一下System.out.flush()的作用 [Re: zwj0231075] Copy to clipboard
Posted by: why
Posted on: 2006-01-02 11:05

For this kind of question, please check the Java API:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintStream.html#flush()
public void flush()
Flush the stream. This is done by writing any buffered output bytes to the underlying output stream and then flushing that stream.

If you spend a little time to google for System.out.flush(), you should be able to find something similar to the following:
When System.out.print() or System.out.println() is performed, the printed text doesn't go straight to the screen. Instead, the text gets sent to a special memory buffer, from which it will eventually be written to the screen. However, sometimes events can occur that will stop the buffer from being written to the screen (another process may write to the screen, for example). System.out.flush() forces the buffer to be immediately written to the screen

https://classes.yale.edu/cpsc112a/help/faq.html#flush


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923