简体   繁体   English

验证文件是否存在于特定的 ftp 服务器位置

[英]Validating if a file exists in specific ftp server location

I need to verify if the file has been completed and generated in a specific ftp location.我需要验证文件是否已在特定的 ftp 位置完成并生成。 I am using a java project with Kube.netes - spring boot and I am wondering if there is a way to do a check on a given ftp server, do I need to write a shell script that needs to be executed?我在 Kube.netes - spring 引导中使用 java 项目,我想知道是否有办法检查给定的 ftp 服务器,我是否需要编写需要执行的 shell 脚本?

The file I am checking if it exists, it is saved in kube.netes persistence volume, and nifi will copy this file into another ftp server.我正在检查的文件是否存在,它保存在 kube.netes 持久卷中,nifi 会将此文件复制到另一台 ftp 服务器。 Kube.netes has the configuration of the volume along with the mounting, but not for the other ftp server which nifi will be using. Kube.netes 具有卷的配置以及安装,但没有用于 nifi 将使用的其他 ftp 服务器。 Thank you谢谢

using apache common.net library can help you here使用 apache common.net 库可以在这里帮助你

pom.xml dependency: pom.xml 依赖:

<dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>3.8.0</version>
</dependency>

//code snippet //代码片段

boolean checkDirectoryExists(String dirPath) throws IOException {
    ftpClient.changeWorkingDirectory(dirPath);
    returnCode = ftpClient.getReplyCode();
    if (returnCode == 550) {
        return false;
    }
    return true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM