Search code examples
javaftp-clientapache-commons-net

check if a directory exists using FTPClient


I'm using FTPClient (org.​apache.​commons.​net.​ftp.​FTPClient) to upload some files to a FTP server.
I need to check if parent directories exists or not; and create them if needed.
How can I check file/directory existence using FTPClient?

Thanks


Solution

  • You want the FTP STAT command.

    You can use this API call to check what you're after.