我遇到了FTPClient.lists()的问题。密码和用户名在filezilla中正常工作,但是,如果我尝试连接使用我的代码:
try {
ftp.setMLSDPolicy(FTPClient.SECURITY_FTP);
ftp.connect(host, port);
ftp.login(un, pw);
try {
FTPFile l[] = ftp.list();
for (FTPFile fTPFile : l) {
System.out.println(fTPFile.getName());
}
} catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException | FTPDataTransferException | FTPAbortedException | FTPListParseException ex) {
Logger.getLogger(testFTP.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("OKE");
} catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException ex) {
Logger.getLogger(testFTP.class.getName()).log(Level.SEVERE, null, ex);
}
出现异常错误:
it.sauronsoftware.ftp4j.FTPIllegalReplyException
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.readFTPReply(FTPCommunicationChannel.java:201)
at it.sauronsoftware.ftp4j.FTPClient.openPassiveDataTransferChannel(FTPClient.java:3614)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.java:3549)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2078)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2273)
at rekon.Module.testFTP.listFiles(testFTP.java:53)
at rekon.Module.testFTP.main(testFTP.java:67)
我在filezilla应用程序中尝试使用用户名和密码才能正常工作。