问题描述
FTPFile [] subFiles = ftpClient .listFiles( 目录);
虽然目录是有效的,但是在调用listFiles时代码被卡住了,可能是什么原因。 ?另外我想提一下,访问同一个FTP服务器的单独的netbeans项目可以使用相同的代码正常工作,但是maven项目存在这个问题。
请帮助。
尝试使用。我假设你正在使用最新的图书馆(你没有写过你正在使用的库)。
接下来的方法,尝试更改文件列表布局。公共资源库使用自动检测,但在某些情况下,这不起作用。您可以更改(和测试)另一个文件列表布局,如下所示:
FTPClientConfig配置=新FTPClientConfig(FTPClientConfig.TEST_YOURSELF);
FTPClient yourClient = FTPClient(...);
client.configure(conf);
I am trying to list all the files under a specific directory in a ftp server.
FTPFile[] subFiles = ftpClient.listFiles("directory");
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.
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不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!