I have a buffered writer, How can I make it put text file in the user's desktop, currently I have to specify a location and I cannot choose it to be the user's desktop location, doesn't matter who is logged in.
private static void writingFile() {
        try {
            BufferedWriter writeArrayList = new BufferedWriter (new FileWriter("D:\\text.txt"));
            for(GetArray s : arrayList){
                writeArrayList.write(s.toString() + "\r\n");
            }
            writeArrayList.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
Thanks.
---------------------Edited----------------------------Code improved-----------
try {
        File homeDir = new File(System.getProperty("user.home"));
        File file = new File(homeDir, "Desktop");
        FileOutputStream oStream = new FileOutputStream(file);
        BufferedWriter writeArrayList = new BufferedWriter(new OutputStreamWriter(oStream));
            for(GetArray s : arrayList){
                writeArrayList.write(s.toString() + "\r\n");
            }
            writeArrayList.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
     
    