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?
FTPClient ftpClient=null;
(ftpClient = new FTPClient()).connect("xxx.xxx.xxx.xxx");
if(ftpClient.login("user", "pass")){
System.out.println(ftpClient.cwd("folder/subfolder"));
***// if returns 250, folder exists and if returned 550 folder does not exist***
}
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more