mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
解决FtpTest.java的downloadTest下载会将文件夹下载成文件的问题
This commit is contained in:
parent
47479f45a7
commit
c4c2bde0b4
@ -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…
x
Reference in New Issue
Block a user