@Override public boolean logout() throws IOException { return client.logout(); }
/** * 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 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); } }
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); } }
} finally { try { ftpClient.logout(); } catch (Exception e2) {
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();