问题描述
我正在尝试列出 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);
这篇关于FTPClient.listFiles 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)