Java BufferedWriter close()

rakeshr picture rakeshr · Jun 2, 2010 · Viewed 8.2k times · Source

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?

Answer

OscarRyz picture OscarRyz · Jun 2, 2010

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

Yes