@Override public void close() throws IOException { this.client.logout(); if (this.client.isConnected()) { this.client.disconnect(); } } }
@Override public void close() throws IOException { this.client.logout(); if (this.client.isConnected()) { this.client.disconnect(); } } }
@Override public void destroyObject(PooledObject<FTPClient> p) throws Exception { try { p.getObject().logout(); } finally { p.getObject().disconnect(); } }
FTPClient ftpClient = new FTPClient(); ftpClient.connect(InetAddress.getByName(server)); ftpClient.login(user, password); ftpClient.changeWorkingDirectory(serverRoad); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); BufferedInputStream buffIn = null; buffIn = new BufferedInputStream(new FileInputStream(file)); ftpClient.enterLocalPassiveMode(); ftpClient.storeFile("test.txt", buffIn); buffIn.close(); ftpClient.logout(); ftpClient.disconnect();
client.logout(); } catch (IOException e) { e.printStackTrace();
/** * Logout and disconnect the given FTPClient. * * * @param client * @throws IOException */ private void disconnect(FTPClient client) throws IOException { if (client != null) { if (!client.isConnected()) { throw new FTPException("Client not connected"); } boolean logoutSuccess = client.logout(); client.disconnect(); if (!logoutSuccess) { LOG.warn("Logout failed while disconnecting, error code - " + client.getReplyCode()); } } }
@Override public synchronized void close() throws IOException { if (closed) { return; } super.close(); closed = true; if (!client.isConnected()) { throw new FTPException("Client not connected"); } boolean cmdCompleted = client.completePendingCommand(); client.logout(); client.disconnect(); if (!cmdCompleted) { throw new FTPException("Could not complete transfer, Reply Code - " + client.getReplyCode()); } }
Logger.debug(LOG_TAG, "Logout and disconnect from FTP server: " + params.serverUrl + ":" + ftpParams.port); ftpClient.logout(); ftpClient.disconnect(); } catch (Exception exc) {
out.close(); if (result) Log.v("download result", "succeeded"); con.logout(); con.disconnect();
public void goforIt(){ FTPClient con = null; try { con = new FTPClient(); con.connect("192.168.2.57"); if (con.login("Administrator", "KUjWbk")) { con.enterLocalPassiveMode(); // important! con.setFileType(FTP.BINARY_FILE_TYPE); String data = "/sdcard/vivekm4a.m4a"; FileInputStream in = new FileInputStream(new File(data)); boolean result = con.storeFile("/vivekm4a.m4a", in); in.close(); if (result) Log.v("upload result", "succeeded"); con.logout(); con.disconnect(); } } catch (Exception e) { e.printStackTrace(); } }
@Override public void closeConnection() { if(ftpClient!=null) { // Try to logout, this may fail if the connection is broken try { ftpClient.logout(); } catch(IOException e) {} // Close the socket connection try { ftpClient.disconnect(); } catch(IOException e) {} ftpClient = null; } }
/** * Close ftp client. * * @throws IOException the io exception */ public void closeFtpClient() throws IOException { ftpClient.logout(); ftpClient.disconnect(); }
@Override public void closeConnection() throws IOException { if (client != null && client.isConnected()) { client.logout(); } } }
public static void ftpDisconnect(FTPClient ftp) { if (ftp.isConnected()) { try { ftp.logout(); ftp.disconnect(); } catch (Exception ioe) { LOGGER.error("Exception while disconnecting ftp", ioe); } } LOGGER.debug("FTP has been successfully disconnected."); }
public static void ftpDisconnect(FTPClient ftp) { if (ftp.isConnected()) { try { ftp.logout(); ftp.disconnect(); } catch (Exception ioe) { LOGGER.error("Exception while disconnecting ftp", ioe); } } LOGGER.debug("FTP has been successfully disconnected."); }
@Override public void disconnect() throws FtpException { try { ftpClient.logout(); if (ftpClient.isConnected()) { ftpClient.disconnect(); } } catch (IOException e) { /*ignore */ } }
protected void disconnect(SocketClient client) throws Exception { FTPClient ftp = (FTPClient) client; if (ftp.isConnected()) { ftp.logout(); } super.disconnect(client); }
public static void download(Config config, String source, String target) throws Exception { System.out.println("Start to download file " + source + " to " + target); try (FtpClient ftp = new FtpClient(config)) { ftp.connect(); try (InputStream in = ftp.getClient().retrieveFileStream(source)) { Files.copy(in, Paths.get(target), StandardCopyOption.REPLACE_EXISTING); } ftp.getClient().logout(); } System.out.println("The file " + target + " has been downloaded."); }
FTPClient ftp = new FTPClient(); ftp.connect("ftp.example.com"); ftp.login("username", "password"); ftp.storeFile("image.jpg", input); // <-- Here, it's just InputStream. ftp.logout();
public static void mkdir(Config config, String path) throws Exception { try (FtpClient ftp = new FtpClient(config)) { ftp.connect(); ftp.makeDirectories(path); ftp.getClient().logout(); } }