title: Desktop path for file output Java
body: <p>I have this program where it will output a text file and save it in the user's computer, I wanted to save it at desktop since that's the path everyone would have. </p>
  
  <p>I'm currently coding in Windows 8, which path should I use to guarantee it'll save to desktop on Windows 7??</p>
  
  <pre><code>File file = new File("C:/Users/Wil/Downloads/Dropbox/abc.txt");
  
          // if file doesnt exists, then create it
          if (!file.exists()) {
              file.createNewFile();
          }
  
          FileWriter fw = new FileWriter(file.getAbsoluteFile());
          BufferedWriter bw = new BufferedWriter(fw);
          bw.write(content);
          bw.close();
  
          JOptionPane.showMessageDialog(null,"Receipt Saved!");
  </code></pre>