FTPClient.listFiles 不工作

2022-11-11Java开发问题
153

本文介绍了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 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13