title: File renameTo does not work
body: <p>I am trying to add an extension to the name of file selected by a <code>JFileChooser</code> although I can't get it to work.</p>
  
  <p>This is the code :</p>
  
  <pre><code>final JFileChooser fc = new JFileChooser();
          fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          int returnVal = fc.showSaveDialog(null);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
              File f = fc.getSelectedFile();
              String name =f.getAbsoluteFile()+".txt";
              f.renameTo(new File(name));
              FileWriter fstream;
              try {
                  fstream = new FileWriter(f);
                  BufferedWriter out = new BufferedWriter(fstream);
                  out.write("test one");
                  out.close();
              } catch (IOException ex) {
                  Logger.getLogger(AppCore.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
  </code></pre>
  
  <p>I can't figure out why this doesn't work. I also tried using getPath() and getCanonicalPath() but the result is the same. The file is created at the directory selected, although without a ".txt" extension.</p>