现在的位置: 首页 > 综合 > 正文

Out输出对象clear(),clearBuffer()和flush()的区别

2018年01月25日 ⁄ 综合 ⁄ 共 1013字 ⁄ 字号 评论关闭

clear:

As the name implies, the clear method of out object is used to clear the output buffer. This method does not write any contents to the client. An exception is thrown by this method if the buffer was flushed.

General syntax of clear method of out object is as follows:
out.clear();

clearBuffer:
The clearBuffer method of out object is used to clear the output buffer. This method does not write any contents to the client.

The only difference between the clear method of out object and clearBuffer method is
clear method throws an exception when the buffer is flushed.
clearBuffer method does not throw an exception when the buffer is flushed.
General syntax of clearBuffer method of out object is as follows:
out.clearBuffer();

flush:
Two methods of out object, clear and clearBuffer are used to clear the output buffer without writing any contents to the client. If you wish to flush the buffer and write contents to the client, then you can use the flush method of out object. The flush method
of out object is used to flush the buffer by writing the contents to the client.

General syntax of flush method of out object is as follows:

out.flush();


参考文章:http://blog.sina.com.cn/s/blog_73cdc7a601018xhx.html

【上篇】
【下篇】

抱歉!评论已关闭.