Hello everybody!

I’m starting to use commons net library in a java project, and I have this doubt: I need to list files in a ftp server, for instance, like this “action*/slot*-qual*.txt”

i.e., I want to list all the files like “slot (something) – qual (something) .txt”, in all directorys beginning with “action”.

When I put this path in a variable named “path” and pass it to the listFiles method, it returns me a list of zero files. But, for instance, if I only pass the path “action*”, the listFiles returns me all the directories beginning with “action”, like action01, action02, etc. The same happens if I pass only  “slot*-qual*.txt”, giving me all the files that respect the command, within a certain directory, like slot1-qual101010.txt, slot2-qual10.txt, slot3-qual1.txt, etc.

So, there’s must me a method to do this kind of listing, isn’t it? Is it possible to list the files like this?

 

If I put the command “ls action*/slot*-qual*.txt” in an ftp client that I use, I get the correct list that I need, so it works like this!

 

Thanks a lot everybody!

André Augusto

 

FTPClient ftp;

FTPFile[] files;

files=ftp.listFiles(path);

for (int i=0; i<files.length; i++)

{

            logger.info("Index: "+i+ " -> Name: " +files[i].getName());

}

 

Reply via email to