java - How to set path to file -


I am creating a simple program that saves everything from JTextArea to file. So I would like to know how to set the path that fits for any user using this program. Example: C: \ Users \ A User \ Desktop \ file.txt

You can use System Properties You can find the user directory "user.home" and then search the desktop directory.

  file path = new file (System.getProperty ("user.home"), "desktop \ file.txt");  

Stay tuned, because this code will work only in Windows * Ux system, you will not have any desktop directory in the user's directory.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -