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

mysql - How to enter php data into a html multiple select box -

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

c++ - Cassandra datastax cpp driver - avoiding unnecessary copies -