FTPClient.listFiles not working(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);
这篇关于FTPClient.listFiles 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:FTPClient.listFiles 不工作
基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
