[英]Validating if a file exists in specific ftp server location
我需要驗證文件是否已在特定的 ftp 位置完成並生成。 我在 Kube.netes - spring 引導中使用 java 項目,我想知道是否有辦法檢查給定的 ftp 服務器,我是否需要編寫需要執行的 shell 腳本?
我正在檢查的文件是否存在,它保存在 kube.netes 持久卷中,nifi 會將此文件復制到另一台 ftp 服務器。 Kube.netes 具有卷的配置以及安裝,但沒有用於 nifi 將使用的其他 ftp 服務器。 謝謝
使用 apache common.net 庫可以在這里幫助你
pom.xml 依賴:
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
//代碼片段
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.