我需要使用ftp从服务器获取日期。我看到了这段代码,并希望它能起作用:
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPCmd;
import org.apache.commons.net.ftp.FTPReply;
FTPClient ftpClient = new FTPClient();
ftpClient.connect(host);
boolean login = ftpClient.login(user, pass);
if (login) {
int replyCode = ftpClient.sendCommand(FTPCmd.GET_MOD_TIME, "date");
if (!FTPReply.isPositiveCompletion(replyCode)) {
System.out.println("The operation did not succeed!");
} else {
System.out.println(ftpClient.getReplyString());
}
}
但是这样做我得到了否定回答:
"操作没有成功!"