Java BufferedWriter close() [英] Java BufferedWriter close()

查看:394
本文介绍了Java BufferedWriter close()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有下面的代码片段:

  operation1(); 
bw.close();
operation2();

当我调用 BufferedReader.close()从我的代码,我假设我的JVM进行系统调用,确保缓冲区已被刷新并写入磁盘。我想知道是否 close()等待系统调用来完成它的操作,或者是否继续到 operation2()不用等待 close()来完成。

为了解释我的问题,当我做 operation2(),我可以假设 bw.close()已经成功完成了吗?

解决方案


当我操作2()时,我可以假设bw.close()已经成功完成吗?



Assume that I have the following code fragment:

operation1();
bw.close();
operation2();

When I call BufferedReader.close() from my code, I am assuming my JVM makes a system call that ensures that the buffer has been flushed and written to disk. I want to know if close() waits for the system call to complete its operation or does it proceed to operation2() without waiting for close() to finish.

To rephrase my question, when I do operation2(), can I assume that bw.close() has completed successfully?

解决方案

when I do operation2(), can I assume that bw.close() has completed successfully?

Yes

这篇关于Java BufferedWriter close()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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