Example usage for org.apache.commons.net.ftp FTPClient connect

List of usage examples for org.apache.commons.net.ftp FTPClient connect

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPClient connect.

Prototype

public void connect(InetAddress host) throws SocketException, IOException 

Source Link

Document

Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port.

Usage

From source file:vv.main.java

private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackupActionPerformed
    // TODO add your handling code here:
    Conectar con = new Conectar();
    String nombreCarpeta = "FTF_" + con.getTime("dd-MM-yyyy") + "_" + con.getTime("HHmm");
    con.createDir("c:\\tmp\\" + nombreCarpeta);
    FTPClient client = new FTPClient();

    String sFTP = con.IP_FTP;/*  w  ww .jav a  2 s.  c o  m*/
    String sUser = con.USUARIO_FTP;
    String sPassword = con.PASSWORD_FTP;
    txtLog.setText("INICIO: " + con.getTime("dd-MM-yyyy HH:mm:ss"));
    try {
        client.connect(sFTP);
        boolean login = client.login(sUser, sPassword);
        con.copiarDir(client, nombreCarpeta);
        client.logout();
        client.disconnect();
    } catch (Exception e) {
        System.out.println("Error:" + e);
    }
    txtLog.setText(txtLog.getText() + "\nFIN: " + con.getTime("dd-MM-yyyy HH:mm:ss"));
}