使用我的Java程序,我将连接到一个带有Apache的FTP服务器。FTP服务器用作我的软件的更新服务器,目前每次我检查更新时,更新程序都会下载一个.txt,并检查写入文件中的版本号是否大于当前安装在计算机上的版本号。
是否有方法从FTP服务器的欢迎消息中获取计算机上软件更新的版本号?那么,我不必下载.txt来检查更新,而只能连接到服务器,并检查欢迎消息的号码?
发布于 2016-03-11 14:32:53
欢迎信息实际上是对连接的“响应”。
因此,在使用FTPClient.connect()连接之后,使用FTPClient.getReplyStrings()检索欢迎消息。
ftp.connect(server);
// After connection attempt, you should check the reply code to verify success.
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
// read the initial response (aka "Welcome message")
String[] welcomeMessage = ftp.getReplyStrings();https://stackoverflow.com/questions/35938586
复制相似问题