title: how to confirm java BufferedWriter successfully wrote to a text file
body: <p>Making random password generator. Once password is generated, which I have no problem doing, the password is saved to a text file. I placed my <code>BufferedWriter</code> in a <em>try-with-resources</em> block, and have a catch block following, so i am notified if there is an <code>IOException</code>. But I want to somehow print(to the console) whether or not the password was actually written into the text file containing every password that i have randomly generated using this program.</p>
  
  <pre><code>// password generator above
  // Export passwords to txt file to save:
  
          File destination = new File("/Users/danielpersonius/Desktop/random passwords.txt");
          if(!destination.exists()){
              destination.createNewFile();
          }
              try(BufferedWriter bw = new BufferedWriter(new FileWriter(destination.getAbsoluteFile(),true))){
                  // FileWriter(path, true) assures that the BufferedWriter appends to the previously created 
                  // text file, not overwrites
                  String formatted_output = String.format("%s%n", password);
                  bw.write(formatted_output);
                  Thread.sleep(1000); System.out.println("Password Successfully saved to \"random passwords.txt\"");
              }catch(IOException e){
                 System.err.println("Export error: " + e.getMessage());
              }
  </code></pre>
  
  <p>Right now, the program automatically prints <code>Successfully saved...</code>, but is  there some way to actually test if it was, and print <code>Unsuccessful</code> if it was not written to the text file? </p>
  
  <p>EDIT: Would a failure to write just show up in my catch block? </p>