Issue
I need to create a .txt
file in the invoices folder. I am using Windows 10. How can I do that? I've tried:
File myObj = new File("\\invoice\\filename.txt");
and
File myObj = new File("/invoice/filename.txt");
But it did not work. Thank you for your support.
Solution
As Jens said do not use a project source folder to write the file.
At run-time of the standalone application there might not be a folder invoice
,
and also you might risk compiling a garbage file into the application jar.
The user's home directory is System.getProperty("user.home")
and work from there on. That is the appropriate directory tree for user specific files.
Answered By - Joop Eggen
Answer Checked By - Mildred Charles (JavaFixing Admin)