Validating if a file exists in specific ftp server location Validating if a file exists in specific ftp server location kubernetes kubernetes

Validating if a file exists in specific ftp server location


using apache common net library can help you here

pom.xml dependency:

<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;}