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.
I'm currently coding in Windows 8, which path should I use to guarantee it'll save to desktop on Windows 7??
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!");
                File desktop = new File(System.getProperty("user.home"), "Desktop");
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With