import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;
public class FtpConnectDemo {
public static void main(String[] args) {
FTPClient client = new FTPClient();
client.connect("ftp.domain.com");
boolean login = client.login("admin", "secret");
if (login) {
System.out.println("Login success...");
boolean logout = client.logout();
if (logout) {
System.out.println("Logout from FTP server...");
}
} else {
System.out.println("Login fail...");
}
client.disconnect();
}
}