Checking file existence on FTP server

Mickael Marrache picture Mickael Marrache · May 7, 2012 · Viewed 27.7k times · Source

Is there an efficient way to check the existence of a file on a FTP server? I'm using Apache Commons Net. I know that I can use the listNames method of FTPClient to get all the files in a specific directory and then I can go over this list to check if a given file exists, but I don't think it's efficient especially when the server contains a lot of files.

Answer

Christopher Creutzig picture Christopher Creutzig · May 7, 2012

listFiles(String pathName) should work just fine for a single file.