【发布时间】:2021-04-09 11:54:12
【问题描述】:
我正在尝试使用 Spring Integration 检查 FTP 服务器中的文件是否存在,但它似乎不起作用。它适用于目录但不适用于文件。在文档中提到适用于目录和文件。我是否正确构建了路径?
private DefaultFtpSessionFactory getFTPFactory() {
DefaultFtpSessionFactory defaultFtpSessionFactory = new DefaultFtpSessionFactory();
defaultFtpSessionFactory.setHost("localhost");
defaultFtpSessionFactory.setPort(21);
defaultFtpSessionFactory.setUsername("foo");
defaultFtpSessionFactory.setPassword("pass");
return defaultFtpSessionFactory;
}
public boolean getFTPFiles() throws IOException {
DefaultFtpSessionFactory defaultFtpSessionFactory = getFTPFactory();
FtpSession ftpSession = defaultFtpSessionFactory.getSession();
FTPClient clientInstance = ftpSession.getClientInstance();
clientInstance.enterLocalPassiveMode();
return ftpSession.exists("/ftp/foo/study/download/test_1.txt");
}
【问题讨论】:
标签: ftp spring-integration spring-integration-ftp