FTPSClient ftpClient = new FTPSClient(); ftpClient.connect(host); ftpClient.login(user, password);
public static void main(String[] args) { FTPSClient ftp = new FTPSClient(); String host = "server.com"; int port = 2121; String folderName = "dir"; String username = "user"; String password = "password"; try { ftp.connect(host, port); ftp.login(username, password); InputStream fis = new FileInputStream("../filename_src.txt"); ftp.storeFile("/" + folderName + "/filename_dest.xml", fis); fis.close(); ftp.logout(); ftp.disconnect(); } catch (SocketException ex) { Logger.getLogger(FTPSendMessage.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FTPSendMessage.class.getName()).log(Level.SEVERE, null, ex); } }
ftpClient.setBufferSize(1024 * 1024); ftpClient.setConnectTimeout(100000); ftpClient.connect(InetAddress.getByName("ipaddress"), 990); ftpClient.setSoTimeout(100000);
FTPSClient ftpClient = new FTPSClient("tls",false); ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); ftpClient.connect(host, port); int reply = ftpClient.getReplyCode(); if (FTPReply.isPositiveCompletion(reply)) { ftpClient.execPBSZ(0); reply = ftpClient.getReplyCode(); // Check for PBSZ error responses... ftpClient.execPROT("P"); reply = ftpClient.getReplyCode(); // Check for PROT error responses... ftpClient.enterLocalPassiveMode();
this.ftpsConnection.connect(hostname, this.port);
FTPSClient l_ftp = new FTPSClient("SSL", false); l_ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); l_ftp.setAuthValue("SSL"); l_ftp.connect(l_host, l_port); if (!l_ftp.login(l_username, l_password)) { // BAD! } l_ftp.execPBSZ(0L); l_ftp.execCCC(); l_ftp.pwd(); // DO STUFF l_ftp.logout(); l_ftp.disconnect();
ftpClient.connect(InetAddress.getByName(this.remoteHostname), this.remotePort);
@Override public boolean connectClient() throws IOException { boolean isLoggedIn = true; client.setAutodetectUTF8(true); client.setControlEncoding("UTF-8"); client.connect(host, port); client.setFileType(FTP.BINARY_FILE_TYPE); client.enterLocalPassiveMode(); client.login(username, password); int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { client.disconnect(); LogUtils.LOGD(TAG, "Negative reply form FTP server, aborting, id was {}:"+ reply); //throw new IOException("failed to connect to FTP server"); isLoggedIn = false; } return isLoggedIn; }
@Test public void testUnderlyingConnect() throws SocketException, IOException { final FTPSClient client1 = this.init(new FTPSClient(true)); final FTPSClient client2 = this.init(new FTPSClient(true)); try { final String hostname = "localhost"; client1.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); client2.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); } finally { if (client1 != null) { client1.disconnect(); } if (client2 != null) { client2.disconnect(); } } } }
@Test public void testUnderlyingConnect() throws SocketException, IOException { final FTPSClient client1 = this.init(new FTPSClient(true)); final FTPSClient client2 = this.init(new FTPSClient(true)); try { final String hostname = "localhost"; client1.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); client2.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); } finally { if (client1 != null) { client1.disconnect(); } if (client2 != null) { client2.disconnect(); } } } }
setConnected(true); try { ftpsClient.connect(getServer(), getPort()); int replyCode = ftpsClient.getReplyCode();
@Test public void testUnderlyingConnect() throws SocketException, IOException { final FTPSClient client1 = this.init(new FTPSClient(true)); final FTPSClient client2 = this.init(new FTPSClient(true)); try { final String hostname = "localhost"; client1.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); client2.connect(hostname, AbstractFtpsProviderTestCase.getSocketPort()); } finally { if (client1 != null) { client1.disconnect(); } if (client2 != null) { client2.disconnect(); } } } }