code: 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());
        }
      }
    }
docs: Logout and disconnect the given FTPClient. *
  
  @param client
  @throws IOException