Note close calls flush, so calling both is redundant. I would always call close. I'm not sure what happens in your code if an exception is thrown. It may make sense to call close in a finally clause.
steve souza wrote:Note close calls flush, so calling both is redundant. I would always call close. I'm not sure what happens in your code if an exception is thrown. It may make sense to call close in a finally clause.
The method fw.close calls the method close from OutputStreamWriter class. Although OutputStreamWriter extends the Writer class, it overrides the close method, and its method don't call flush.
If you absolutely, positively HAVE to ensure it got written, call flush(). You can call flush anytime and you can call it as often as you like. If there's nothing to flush, the overhead is minimal.
"Disappointing" and "Utterly Horrible" are not equal.