栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

下载Java中的整个FTP目录(Apache Net Commons)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

下载Java中的整个FTP目录(Apache Net Commons)

您的问题(好吧,在我们摆脱

.
和之后
..
,您已经解决了二进制问题),这是您在调用之前执行递归步骤
newDir.mkdirs()

所以假设你有一棵像

...someDir   .   ..   someFile.txtsomeOtherDir   .   ..someOtherFile.png

您要做的是跳过点文件,看到它

someDir
是目录,然后立即进入其中,跳过其点文件,然后查看
someFile.txt
并处理它。您尚未在
someDir
本地创建,因此会出现异常。

您的异常处理程序不会停止执行,因此控制权返回到递归的上层。此时,它将创建目录。

因此,下次运行程序时,本地

someDir
目录已从上一次运行中创建,您不会发现任何问题。

基本上,您应该将代码更改为:

 if (file.isDirectory()) {     // Change working Directory to this directory.     ftpClient.changeWorkingDirectory(file.getName());     // Create the directory locally - in the right place     File newDir = new File (base + "/" + ftpClient.printWorkingDirectory());     newDir.mkdirs();     // Recursive call to this method.     download(ftpClient.printWorkingDirectory(), base);     // Come back out to the parent level.     ftpClient.changeToParentDirectory(); }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/498666.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号