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

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

问题描述

我需要知道 Java 中刷新和关闭函数之间的确切区别是什么?

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天全站免登陆