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

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

Introduction

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

Prototype

public void connect(InetAddress host, int port) throws SocketException, IOException 

Source Link

Document

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

Usage

From source file:progparallele.Main.java

public static void testFTPChunks() {
    FTP ftp = new FTP();
    try {/*from w w w .j  av a 2s .  com*/
        ftp.connect(hostname, port);
        int reply = ftp.getReplyCode();
        if (reply != 220) {
            ftp.disconnect();
            return;
        }

        ftp.user("anonymous");
        ftp.pass("");

        ftp.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
    }
}