FTP 客户端 - 列表文件
我无法使用 FTPClient 获取确切的文件列表。示例代码如下:
FTPClient client = new FTPClient();
client.connect("x.x.x.x");
client.login("abcd", "abcd");
FTPFile[] ftpFiles = client.listFiles();
for (FTPFile ftpFile : ftpFiles) {
System.out.println("FTPFile: " + ftpFile.getName());
}
我尝试使用enterLocalPassiveMode()/enterRemotePassiveMode()/pasv()设置为PASV模式。但是,这不起作用。
另请检查 Apache Commons FTPClient.listFiles ..
谢谢
I am unable to get the exact file list using FTPClient. Sample code as below :
FTPClient client = new FTPClient();
client.connect("x.x.x.x");
client.login("abcd", "abcd");
FTPFile[] ftpFiles = client.listFiles();
for (FTPFile ftpFile : ftpFiles) {
System.out.println("FTPFile: " + ftpFile.getName());
}
I tried to set to PASV mode using enterLocalPassiveMode()/enterRemotePassiveMode()/pasv(). But, it doesnt work.
Please also check Apache Commons FTPClient.listFiles ..
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道
files
是什么,但您在ftpFiles
中获得client.listFiles
的结果,而不是在中文件
。然后在for
循环中遍历文件
。I don't know what
files
is, but you're getting the results ofclient.listFiles
inftpFiles
, and not infiles
. Then in yourfor
loop you go overfiles
.试试这个。
这应该有效。
谢谢。
Try this.
This should work.
Thanks.