[英]Java ftp4j - List files in FTP server when connecting in amn active mode
我正在使用ftp4j庫實現我的FTP客戶端,但是我嘗試連接的服務器僅在活動模式下接受連接。
因此,當我嘗試列出遠程文件時,我得到了:
ERROR : Error in Connecting to Remote Machine... Hence exitting...
it.sauronsoftware.ftp4j.FTPException [code=501, message= Server cannot accept argument.]
at it.sauronsoftware.ftp4j.FTPClient.openActiveDataTransferChannel(FTPClient.java:3600)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.java:3551)
at it.sauronsoftware.ftp4j.FTPClient.listNames(FTPClient.java:2335)
at com.npap.network.TranferFileFtp4j.listRemoteFilesFtp1(TranferFileFtp4j.java:999)
這是代碼:
...
//connect to server method - in active mode!
ftpClient = Ftp4jUtility.connect1(SERVER_MACHINE, PORT, SERVER_USERNAME, SERVER_PASSWORD);
try {
ftpClient.changeDirectory(config.getFtpRemoteFolderReports());
log.info("Changed directory to: " + config.getFtpRemoteFolderReports());
} catch (FTPException | FTPIllegalReplyException | IOException | IllegalStateException e) {
e.printStackTrace();
}
String[] filesList = ftpClient.listNames();
for(String f: filesList) {
log.info("fetched file: " + f);
tmpAllRemoteFiles.add(f);
}
在活動模式下連接時,有什么辦法列出遠程文件?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.