venkat2010
venkat2010

Reputation: 607

Upload file using java in ftp

I want to upload file from my system to remote server as ftp.how i am to resolve this.I am using FTPClient client = new FTPClient(); and client.connect("sftp://something.com");But i am unable to connect it how i am check weather problem with my code or url.like ping command

Upvotes: 1

Views: 700

Answers (2)

Miserable Variable
Miserable Variable

Reputation: 28761

I haven't used FTPClient (assume you mean Apache Commons FTPClient but a quick browse of apidocs shows two errors in your use:

  1. The parameter to connect is server name, not url: client.connect("sftp://something.com") should be client.connect("something.com")
  2. If you are using sftp you have to use FTPSClient

Upvotes: 3

Shivan Dragon
Shivan Dragon

Reputation: 15229

If you're connecting to an Sftp you might need to add the appropriate certificates (public/private keys) to the JVM where the code is running. Try your code on a regular FTP connection first, if that works, but not the sftp connections, it's almost sure is because of that.

Upvotes: 0

Related Questions