2011-01-21 8 views
3

私はFTPCLientクラスのapache commons net APIを使用してFTPサーバーに接続するプログラムを作成しています。ここにコード:Apache Commons Net APIの使用

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(0).byteValue(); 
    b[ 3] = new Integer(1).byteValue(); 
    try{ 

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

     } 

..... 私はconnect line()で例外が発生します。

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

答えて

2

この

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

注意してみてください。そのsftpの場合はポート22はSSHのため、SFTPないFTP

のために使用されている、あなたはcommons-vfs

のために行く必要があります