mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
Merge pull request #2804 from zhaoshengwolf/v5-master
解决FtpTest.java的downloadTest下载会将文件夹下载成文件的问题
This commit is contained in:
commit
edcbbb8396
@ -91,12 +91,19 @@ public class FtpTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void downloadTest() {
|
public void downloadTest() {
|
||||||
try(final Ftp ftp = new Ftp("localhost")){
|
String downloadPath = "d:/test/download/";
|
||||||
final List<String> fileNames = ftp.ls("temp/");
|
try (final Ftp ftp = new Ftp("localhost")) {
|
||||||
for(final String name: fileNames) {
|
final List<FTPFile> ftpFiles = ftp.lsFiles("temp/", null);
|
||||||
ftp.download("",
|
for (final FTPFile ftpFile : ftpFiles) {
|
||||||
name,
|
String name = ftpFile.getName();
|
||||||
FileUtil.file("d:/test/download/" + name));
|
if (ftpFile.isDirectory()) {
|
||||||
|
File dp = new File(downloadPath + name);
|
||||||
|
if (!dp.exists()) {
|
||||||
|
dp.mkdir();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ftp.download("", name, FileUtil.file(downloadPath + name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user