开发者

Apache Commons Net API usage

开发者 https://www.devze.com 2023-02-06 10:49 出处:网络
I am making a program to connect to FTP Server using FTPCLient class of apache commons net API. here is code:

I am making a program to connect to FTP Server using FTPCLient class of apache commons net API. here is code:

    FTPClient client = new FTPClient();
    byte[] b = new byte[4];
    b[ 0] = new Integer(127).byteValue();
    b[ 1] = new Integer(0).byteValue();
    b[ 2] = new Integer(开发者_Go百科0).byteValue();
    b[ 3] = new Integer(1).byteValue();
    try{

            InetAddress address = InetAddress.getByAddress(b);
        client.connect(address,22);

       }

..... I get the exception at connect line().

org.apache.commons.net.MalformedServerReplyException: Could not parse response code.


Try with this

 FTPClient f = new FTPClient();
 f.connect(server);
 f.login(username, password);
 FTPFile[] files = listFiles(directory);

Note: port 22 is used for SSH,sftp not for ftp

If its sftp then you need to go for commons-vfs

0

精彩评论

暂无评论...
验证码 换一张
取 消