Apache Commons FTPClient, check if remote directory exist and get permissions (linux - unix)

Xerg picture Xerg · Dec 21, 2010 · Viewed 21.6k times · Source

Is it possible with FTPClient (Apache commons-net) to check if a remote directory exists?

I want to do something like this:

ftp.isDirectory(String path) //returns true, false

And then get permissions (chmod) of directory:

ftp.getPermisions(String path) //returns -rwxr-xr-x 

Answer

Juris picture Juris · Jul 1, 2011

Try to change the working directory to the directory you need to check:

boolean directoryExists = FTPClient.changeWorkingDirectory("path/to/somedir")