Reputation: 215
I need to design a executable .jar which makes two text files, I want that whenever I double click the executable jar, it automatically transfer the file path to a string so that I can use it in my fileWriter up its directory so that I could give the same path for my text files.
currently I had entered the path manually in my code file. which is useless for me.
FileWriter write = new FileWriter ("D:/final project/report.txt", false);
BufferedWriter bufferedWriter = new BufferedWriter (write);
Upvotes: 1
Views: 247
Reputation: 21831
I think you could use System.getProperty("user.dir")
which will return current directory path.
Upvotes: 2