How should I check if BufferedWriter is already closed?
In android, I am writing a file on clicking a button and on clicking next time, it saves the file and closes the buffered writer. But, I also want to implement functionality to close the buffered writer in onDestroy function. Before that I need to know if Bufferedwriter is already closed. How will I check if Buffered Writer is already closed? In addition to that, does bufferedWriter.close() function set bufferedWriter to null ? Calling close method on already closed Writer has no impact. Still, if you want to know if the Writer is closed, you can call writer.flush() , if it throws IOException