I have a DownloadTask class in java that takes a filename and URL, downloads that file and saves it to the downloads folder.
To save it to my downloads folder, I have the line
File file = new File("/users/myName/Downloads" + fileName + ".txt");
What can I replace this path with so that anyone can run the program and the file will be saved to their downloads folder?
By default, Chrome, Firefox and Microsoft Edge download files to the Downloads folder located at %USERPROFILE%\Downloads. USERPROFILE is a variable that refers to the logged in user's profile directory on the Windows computer, e.g. the path may look like C:\Users\YourUserName\Downloads.
The Downloads folder you see under iCloud Drive pertains specifically to documents and files you download and access from iCloud Drive. The other Downloads folder is for everything else you download from the internet.
A sliding menu will appear on the right-hand side. Scroll down until you see the View advanced settings button and click on that. Scroll down to the Downloads section. Click the Change button and choose a new location for the downloads.
Check out this question. Use...
String home = System.getProperty("user.home"); File file = new File(home+"/Downloads/" + fileName + ".txt");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With