java中filewriter的flush和close函数之间的区别 [英] difference between flush and close function in case of filewriter in java

查看:623
本文介绍了java中filewriter的flush和close函数之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道Java中flush和close函数之间的确切区别是什么?

I need to know what is exact difference between flush and close function in Java?

并且在写入文件期间将数据转储到文件中?

And When the data is dumped into a file during writing of file?

请提供一个例子

推荐答案

flush()写入的内容缓冲区到目标并使缓冲区为空以便存储更多数据,但它不会永久关闭流。这意味着您仍然可以向流中写入更多数据。

flush() writes the content of the buffer to the destination and makes the buffer empty for further data to store but it does not closes the stream permanently. That means you can still write some more data to the stream.

但close()会永久关闭流。如果你想进一步写一些数据,那么你必须再次重新打开流并用现有数据附加数据。

But close() closes the stream permanently. If you want to write some data further, then you have to reopen the stream again and append the data with the existing ones.

这篇关于java中filewriter的flush和close函数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆