I'm making simple program that saves everything from JTextArea to file. So i would like to know how to set path that would fit to any user that uses this program. example: C:\User\Any User\Desktop\file.txt
Asked
Active
Viewed 74 times
1 Answers
0
You can use the system property "user.home" in order to get the user's directory, and then search the Desktop directory.
File path = new File(System.getProperty("user.home"), "Desktop\file.txt");
Be carefully, because this code just will work in Windows. In a *ux system you maybe will don`t have any Desktop directory in the user's directory.

Darkcavie
- 36
- 4