edtFTPj/Free - Open-source FTP library for Java | Download
 How to connect to an FTP server

Connecting to an FTP server with edtFTPj/Free is simply a matter of:

1.    Creating an FileTransferClient object

FileTransferClient ftp = new FileTransferClient();

2.    Setting the remote host and user credentials

ftp.setRemoteHost(host);
ftp.setUserName(username);
ftp.setPassword(password);


3.    Calling the connect() method, which connects to the server and logs in.

ftp.connect();

4.    Logging out and closing the connection.

ftp.disconnect();


The connect() call will return when successfully connected and logged in, or throw an exception if it fails to connect or log in.

Note that the automatic login can be disabled using the advanced settings, which must be obtained via getAdvancedFTPSettings().

ftp.getAdvancedFTPSettings().setAutoLogin(false);

If autologin is disabled, manualLogin() must be be used to log into the server after connect() has been called (and prior to any remote operations being performed):

ftp.connect();
ftp.manualLogin();