FTPClient.listFiles not working

I am trying to list all files in a specific directory on an ftp server.

FTPFile[] subFiles = ftpClient.listFiles("directory"); 

Although the directory is valid, but the code gets stuck while calling listFiles, what could be the reason.? Further, I would like to mention that a separate netbeans project accessing the same FTP server works fine with the same code, but a problem with the maven project arises. please, help.

+4
source share
1 answer

Try using passive mode . I assume that you are using the latest commons net library (you did not write which library you are using).


Next approach, try changing the layout of the file list. Commons lib uses automatic detection, but in some cases this does not work. You can change (and check) another file list format as follows:

 FTPClientConfig configuration = new FTPClientConfig(FTPClientConfig.TEST_YOURSELF); FTPClient yourClient = FTPClient(...); client.configure(conf); 
+6
source

All Articles