Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.3k views
in Java FTP by
ok, I've managed to cobble together the following test program:
import java.io.*;
import com.enterprisedt.net.ftp.*;

public class ftptst {
    public static void main(String[] args)
        throws IOException, FTPException
    {
        // FTPClient ftp = new FTPClient("192.168.0.2");
        FTPClient ftp = new FTPClient("ftp.arix.com");
        ftp.login("anonymous", "");

        String[] list = ftp.dir();
        print(list);

        ftp.quit();
    }

    private static void print(String[] list) {
        System.out.println("Directory listing:");
        for (int i = 0; i < list.length; i++)
            System.out.println(list[i]);
        System.out.println("Listing complete");
    }
}

but when I run it I get the exception shown in the subject of this posting.. as is evident, I've tried the FTPClient() constructor with _both_ a name and an IP address. what is wrong with the code? (yes I do have an ftp server at that address)

please e-mail me (e@arix.com). thx - ekkis

1 Answer

0 votes
by
I don't know what the problem is, but some suggestions:

1. Supply an email address as password for anonymous
2. Try the identical commands in a command-line client
3. Post the stack trace for us to look at

ok, I've managed to cobble together the following test program:
import java.io.*;
import com.enterprisedt.net.ftp.*;

public class ftptst {
    public static void main(String[] args)
        throws IOException, FTPException
    {
        // FTPClient ftp = new FTPClient("192.168.0.2");
        FTPClient ftp = new FTPClient("ftp.arix.com");
        ftp.login("anonymous", "");

        String[] list = ftp.dir();
        print(list);

        ftp.quit();
    }

    private static void print(String[] list) {
        System.out.println("Directory listing:");
        for (int i = 0; i < list.length; i++)
            System.out.println(list[i]);
        System.out.println("Listing complete");
    }
}

but when I run it I get the exception shown in the subject of this posting.. as is evident, I've tried the FTPClient() constructor with _both_ a name and an IP address. what is wrong with the code? (yes I do have an ftp server at that address)

please e-mail me (e@arix.com). thx - ekkis

Categories

...