@Override public void disconnect() throws IOException { client.disconnect(); }
/** * Disconnect and logout from current connection to server * */ @Override public void disconnect() { try { ftpsClient.logout(); ftpsClient.disconnect(); setConnected(false); } catch (IOException e) { LOGGER.error("Source " + this.getClass().getName() + " failed disconnect", e); } }
/** * Disconnect */ public void disconnect() { logger.debug("Disconnecting..."); //$NON-NLS-1$ try { if(this.ftpClient.logout()) { logger.debug("logout... [OK]"); } else { logger.info("logout... [FAILED], continuing with disconnect..."); } this.ftpClient.disconnect(); logger.debug("Disconnected... [OK]"); //$NON-NLS-1$ } catch (IOException e) { logger.info("Disconnecting... [Failed] due to: ", e); //$NON-NLS-1$ } }
/** * Disconnect from the remote host * * @throws FileTransferException */ @Override public void disconnect() throws FileTransferException { if (this.ftpsConnection != null && this.ftpsConnection.isConnected()) { try { this.ftpsConnection.disconnect(); this.ftpsConnection = null; } catch (IOException e) { throw new FileTransferException(e); } } }
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.disconnect(); } catch (Exception e2) {
this.ftpClient.disconnect(); this.ftpClient.disconnect();
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();
@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(); } } } }
ftpsClient.disconnect(); LOGGER.error("Connect Failed due to FTPS, server refused connection."); this.setConnected(false);
@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(); } } } }