I am using apache-commons-net 3.4 and i found a strange issue i cant explain. I want to get the FTPFile
entries of an directory but when i use FTPClient#listFiles()
an empty array is returned, but FTPClient#listNames()
list all entries.
FTPClient client = new FTPClient();
client.connect("192.168.1.4");
client.enterLocalPassiveMode();
client.login("ftpuser", "ftpuser");
System.out.println( client.listFiles("/").length); // prints 0
System.out.println( client.listNames("/").length); // prints 21
What is going on here how to use listFiles()
correct ?
Related questions that didn't answer my question:
This topic could help you make listFiles
work :
FTPClient.listFiles not working
From the documentation of FtpClient
, the two methods don't work in the same way :
listFiles(String pathname) Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.This information is obtained through the LIST command.
listNames(String pathname) Obtain a list of filenames in a directory (or just the name of a given file, which is not particularly useful).This information is obtained through the NLST command.