-5

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 ?

Community
  • 1
  • 1
hari shankar
  • 27
  • 1
  • 7
  • 1
    Pass 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 Answers1

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