Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Downloading file from FTP using Java  RSS feed

 
Richa Sharma
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I am trying to download files from FTP on a machine in another domain and having password protection.

Do I have to supply the username and password while connecting programatically as shown below. The code as such is not working?

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you do need to provide username and password. They can be passed in as part of the URL; I think the syntax is something like "ftp://username:password@host/file". Searching for "ftp url syntax" will tell you for sure.

Alternatively you can use an FTP client library like Apache Commons Net, which supports more advanced FTP operations like downloading multiple files and uploading files.
 
Richa Sharma
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!