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 不工作


基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01