[Net] I'm having a problem using the listList files method in the FTPClient class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Net] I'm having a problem using the listList files method in the FTPClient class

Daerian
I'm using FTPClient class to write an FTP client. I've searched some
examples on the internet of how to use the class methods. In the various
examples I've found the listFiles method is always used in the same way, but
when I try yo connect to an FTP server and use it I don't get any file. I've
tried several FTP servers and it happens in all of them, also, I've used
variants of the method, calling it with and without parameters. I've
successfuly changed the working directory to a directory that I know that
contains files and it still does not work. This is the piece of code:

 FTPClient f= new FTPClient();
 f.connect(server);
 f.login(user,pssw);

 FTPFile[] files = f.listFiles();
System.out.println("Number of files in the directory: " + files.length);
 for(int i=0;i< files.length;i++){
 System.out.println("files:" + files[i].getName());

I can't find why it does not work. If someone could point me the error I
would appreciate it.

Thanks.