I want to download some files from internet. I found a promising answer in question How to download and save a file from Internet using Java? . How ever I do not know how to save the downloaded files to specific folder say /user/home/Desktop/Download ?
Asked
Active
Viewed 3,169 times
-5
-
1Pass the file location to `FileOutputStream` in the example you are refering. `FileOutputStream fos = new FileOutputStream("/user/home/Desktop/Download/file.txt");` – Jayamohan Dec 17 '13 at 07:43
-
if you want to specify the folder, just add the folder path in your file name – Baby Dec 17 '13 at 07:44
1 Answers
3
You can just give the relative or absolute file path when specifying the file name in the FileOutputStream
.
FileOutputStream fos = new FileOutputStream("/user/home/Desktop/Download/myFile.extn");

Rahul
- 44,383
- 11
- 84
- 103
-
and don't forget to add escape characters for \ if you are in windows. – Barış Akkurt Dec 17 '13 at 07:42