Suppose a Java application writes to a file using BufferedWriter
API (and does not call flush
after every write
). I guess that if the application exits with System.exit
the buffer is not flushed and so the file might be corrupted.
Suppose also that the application component, which decides to exit, is not aware of the component, which writes to the file.
What is the easiest and correct way to solve the "flush problem" ?