Found it!
The thing is you want to enter passive mode after you connect, but before you log in.
Your code returns nothing for me, but this works for me:
import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;
import org.apache.commons.net.ftp.FTPFile;
public class BasicFTP {
public static void main(String[] args) throws IOException {
FTPClient client = new FTPClient();
client.connect("c64.rulez.org");
client.enterLocalPassiveMode();
client.login("anonymous", "");
FTPFile[] files = client.listFiles("/pub");
for (FTPFile file : files) {
System.out.println(file.getName());
}
}
}
Gives me this output:
c128
c64
c64.hu
incoming
plus4
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…