我已经尝试用库commons.net创建一个项目,通过ftp发送一些文件。但我创建了与我的服务器的连接,我收到了这个错误。commons-net与ssh-2.0协议兼容
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-2.0-OpenSSH_5.3
我跟了这article为创建我的连接,并与official examples我已经控制的文章。
我的Java代码在这里:
private void connect(String host, String user, String pwd) {
try{
ftp = new FTPSClient(false);
//ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
int reply;
ftp.connect(host,22);//error is here
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
throw new Exception("Exception in connecting to FTP Server");
}
ftp.login(user, pwd);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
}catch(Exception ex){
ex.printStackTrace();
}
}
我不明白,我哪里错了。
感谢尼克,正常工作与JSch库 –
感谢尼克。这是非常有用的 – Motilal