Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

General Path To Downloads Folder [duplicate]

Tags:

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?

like image 245
user3243242 Avatar asked May 23 '15 18:05

user3243242


People also ask

What is the path to the 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.

Why do I have two download folders?

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.

How do I reassign a download folder?

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.


1 Answers

Check out this question. Use...

String home = System.getProperty("user.home"); File file = new File(home+"/Downloads/" + fileName + ".txt");  
like image 96
Harsh Poddar Avatar answered Oct 26 '22 22:10

Harsh Poddar