FTPClient.listFiles 不工作
我正在尝试列出 ftp 服务器中特定目录下的所有文件.
I am trying to list all the files under a specific directory in a ftp server.
FTPFile[] subFiles = ftpClient.listFiles("directory");
虽然目录是有效的,但调用 listFiles 时代码卡住了,可能是什么原因.?此外,我想提一下,访问同一 FTP 服务器的单独 netbeans 项目使用相同的代码可以正常工作,但是 maven 项目存在问题.请帮忙.
Although the directory is a valid one , but the code gets stuck while calling listFiles , what may be the reason. ? Further i would like to mention that a seperate netbeans project accessing the same FTP server is working fine with the same code , but a maven project is having the problem. please help.
推荐答案
尝试使用被动模式
.我假设你使用的是最新的 commons net 库(你没有写哪个你正在使用的lib).
Try to use passive mode
. I assume that you are using the newest commons net library (you didn't write which lib you are using).
下一个方法,尝试更改文件列表布局.公共库使用自动检测,但在某些情况下这不起作用.您可以更改(和测试)另一个文件列表布局,如下所示:
Next approach, try to change the file list layout. The commons lib uses auto-detection but in some cases this doesn't work. You can change (and test) another file list layout as followed:
FTPClientConfig configuration = new FTPClientConfig(FTPClientConfig.TEST_YOURSELF);
FTPClient yourClient = FTPClient(...);
client.configure(conf);
相关文章