Description
It would be nice if there was a way to list only those files I'm interested in. I've had to write a loop a couple of times to figure out which files had the right naming conventions. If the API handled that for me, I would have less boilerplate code to write.
I would attach a patch but as of this time I cannot download the source due to an internal server error.
I was imagining the introduction of a new interface org.apache.commons.net.ftp.FTPFileFilter that would be analogous to java.io.FileFilter:
package org.apache.commons.net.ftp; public interface FTPFileFilter { public boolean accept(FTPFile file); }
A new method on FTPClient would need to be created to support it. Here's a code sample using API calls:
public FTPFile[] listFiles(FTPFileFilter filter) throws IOException { FTPFile files = listFiles(); List<FTPFile> fileList = new ArrayList<FTPFile>(files.length); for (FTPFile file : files) { if (filter.accept(file)) { fileList.add(file); } } return fileList.toArray(new FTPFile[fileList.size()]); }
See java.io.File.listFiles(java.io.FileFilter) for comparison.
Attachments
Issue Links
- relates to
-
NET-156 New FTPClient method to retrieve all directory names in the current working directory.
- Closed