title: How do you save a txt file with JFileChooser
body: <p>Hey im trying to make a notepad type program and I can't save the file can you help?</p>
  
  <pre><code>save.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event){
              saveFile();
  
              if(fileToSave == JFileChooser.APPROVE_OPTION){
                  try{
                      BufferedWriter out = new BufferedWriter(new FileWriter(Save.getSelectedFile().getPath() + ".txt"));
  
                  }catch(Exception e){
                      System.out.println(e.getMessage());
                  }
              }
          }
      });
  
  public void saveFile(){
          JFileChooser save = new JFileChooser();
          int option = save.showSaveDialog(this);
          fileToSave = option;
          Save = save;
      }
  </code></pre>