title: Java Buffered Writer to publically accessible location
body: <p>I am trying to change a program I wrote a while ago. Currently the program handles a few BufferedReader and BufferedWriters with some logic built in. Let me explain how it used to work.</p>
  
  <p>Class used to upload a file: </p>
  
  <pre><code>public void getFile(){//Used to upload the ACH file. 
  
          while(uploadApproval==false){//While upload approval has not been given..
  
          JFileChooser chooser = new JFileChooser();//Creates a new object of the JFileChooser class. 
  
          uploadFile = chooser;//Saves the upload file variable as the chooser response. 
  
          FileNameExtensionFilter filter = new FileNameExtensionFilter("ACH Files", "ach");
          //Sets the allowed file formats for upload. 
  
          chooser.setFileFilter(filter);//Activates the created file filter.
  
          chooser.setDialogTitle("Please choose ACH file to upload");//Sets the title bar text. 
  
          //Completes once the user clicks ok. 
          int returnVal = chooser.showOpenDialog(chooser);//
          if(returnVal == JFileChooser.APPROVE_OPTION){
              uploadApproval=true;
          }else{
              System.exit(0);
          }
  
      }
  } 
  </code></pre>
  
  <p>Class used to set directory</p>
  
  <pre><code>public void setDirectory(){//Used to set the directory. 
  
          while(saveApproval==false){//While the user does not have approval of the save location..
  
          JFileChooser chooser2 = new JFileChooser();//Creates a new JFileChooser object.
  
          saveFile = chooser2;//Sets the save file location to chooser2. 
  
          chooser2.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//User is only able to scan for 
          //directories. 
  
          //Completes once the user clicks okay. 
          int returnValue2 = chooser2.showDialog(chooser2, "Directory to save");
          if(returnValue2 == JFileChooser.APPROVE_OPTION){
              saveApproval=true;
          }else{
              System.exit(0);
          }
  
          }
  
      }
  </code></pre>
  
  <p>Then later I begin the actual buffered reader/writer process which involves a lot of logic here: </p>
  
  <pre><code>location = "//NachaOutput"+randomNumber+".ACH";
  
          try{
  
              String sCurrentLine;//String representing the current line. 
  
              //Pulls the uploaded file. 
              br = new BufferedReader(new FileReader(NachaMain.uploadFile.getSelectedFile()));
  
  
  
  
              bw = new BufferedWriter(new FileWriter(NachaMain.saveFile.getSelectedFile()+location));
  </code></pre>
  
  <p>Now here is what I need to do. I have been asked to remove the screen where the user selects the directory from the beginning. Instead, the user will select the save directory in the end of the process.</p>
  
  <p>This means that the "SetDirectory" method won't be called at all, therefore this line of code:</p>
  
  <pre><code>bw = new BufferedWriter(new FileWriter(NachaMain.saveFile.getSelectedFile()+location));
  </code></pre>
  
  <p>obviously won't work. I need to find some way to replace that file writer location with a generic location that would be the same for all users regardless of their setup. Something along the lines of documents. </p>
  
  <p>I tried doing this: </p>
  
  <pre><code>bw = new BufferedWriter(new FileWriter("Libraries\\Documents"+location));
  </code></pre>
  
  <p>but got an exception about an invalid path. </p>
  
  <p>So please help me out and let me know a good path that I could save the file to automatically. That saved file will basically be a "dummy" file. Later in the end of the program I will copy that dummy file to the location the user specifies then delete it, so the location really doesn't matter too much.</p>
  
  <p>Thanks in advance!</p>