Problem with FTPClient class in java

后端 未结 2 593
再見小時候
再見小時候 2021-01-12 04:44

I\'m using org.apache.commons.net.ftp.FTPClient and seeing behavior that is, well... perplexing.

The method beneath intends to go through an FTPFile list, read them

相关标签:
2条回答
  • 2021-01-12 04:49

    It works ok when I add after the "retrieve" command :

            int response = client.getReply();
            if (response != FTPReply.CLOSING_DATA_CONNECTION){
                //TODO 
            }
    
    0 讨论(0)
  • 2021-01-12 04:54

    According to the API for FTPClient.retrieveFileStream(), the method returns null when it cannot open the data connection, in which case you should check the reply code (e.g. getReplyCode(), getReplyString(), getReplyStrings()) to see why it failed. Also, you are suppose to finalize file transfers by calling completePendingCommand() and verifying that the transfer was indeed successful.

    0 讨论(0)
提交回复
热议问题