title: FileWriter doesn't write to file even after .flush()/.close()
body: <p>I am trying to write to a text file but even though the method creates the file if it does not exist, it does not write. I have been through several other posts with a similar issue and followed the advice but had no luck.</p>
  
  <p>Through use of the debugger, the String data contains the correct data that should be written but it is never written to the text file.</p>
  
  <p>Any advice on something I've overlooked would be appreciated.</p>
  
  <pre><code>private static void createReservation(String filmName, String date, int noOfSeats, String username) {
      FileWriter fw = null;
      try {
          File bookingFile = new File("C:\\server\\bookinginfo.txt");
          if (!bookingFile.exists())
          {
              bookingFile.createNewFile();
          }
          fw = new FileWriter(bookingFile.getName(),true);
          String data = "&lt;"+filmName+"&gt;&lt;"+date+"&gt;&lt;"+Integer.toString(noOfSeats)+"&gt;&lt;"+username+"&gt;\r\n";
          fw.write(data);
          fw.flush();
      } catch (IOException ex) {
          Logger.getLogger(FilmInfoHandler.class.getName()).log(Level.SEVERE, null, ex);
      } finally {
          try {
              fw.close();
          } catch (IOException ex) {
              Logger.getLogger(FilmInfoHandler.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  }
  </code></pre>