FTP新增读取远程文件输入流方法

This commit is contained in:
kirito
2023-12-22 16:52:55 +08:00
parent de32f87658
commit 41a3379377
5 changed files with 92 additions and 0 deletions

View File

@@ -16,10 +16,13 @@ import org.apache.commons.net.ftp.FTPSClient;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.extra.ssh.engine.jsch.JschSftp;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
public class FtpTest {
@@ -128,6 +131,18 @@ public class FtpTest {
}
}
@Test
@Disabled
public void readTest() throws Exception {
try (final CommonsFtp ftp = CommonsFtp.of("localhost");
final BufferedReader reader = new BufferedReader(new InputStreamReader(ftp.read("d://test/read/", "test.txt")))) {
String line;
while (StrUtil.isNotBlank(line = reader.readLine())) {
Console.log(line);
}
}
}
@Test
@Disabled
public void existSftpTest() {