Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 49189 invoked from network); 3 Jun 2010 13:38:41 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Jun 2010 13:38:41 -0000 Received: (qmail 82715 invoked by uid 500); 3 Jun 2010 13:38:41 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 82639 invoked by uid 500); 3 Jun 2010 13:38:40 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 82631 invoked by uid 99); 3 Jun 2010 13:38:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Jun 2010 13:38:40 +0000 X-ASF-Spam-Status: No, hits=-1494.0 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Jun 2010 13:38:39 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o53DcIvN029116 for ; Thu, 3 Jun 2010 13:38:19 GMT Message-ID: <20213664.158561275572298882.JavaMail.jira@thor> Date: Thu, 3 Jun 2010 09:38:18 -0400 (EDT) From: "Matt Lachman (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (NET-244) Add a FTPClient.listFiles(FTPFileFilter) method In-Reply-To: <1612935040.1227023744342.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/NET-244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Lachman updated NET-244: ----------------------------- 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|http://java.sun.com/javase/6/docs/api/java/io/FileFilter.html]: {code} package org.apache.commons.net.ftp; public interface FTPFileFilter { public boolean accept(FTPFile file); } {code} A new method on FTPClient would need to be created to support it. Here's a code sample using API calls: {code} public FTPFile[] listFiles(FTPFileFilter filter) throws IOException { FTPFile files = listFiles(); List fileList = new ArrayList(files.length); for (FTPFile file : files) { if (filter.accept(file)) { fileList.add(file); } } return fileList.toArray(new FTPFile[fileList.size()]); } {code} See [java.io.File.listFiles(java.io.FileFilter)|http://java.sun.com/javase/6/docs/api/java/io/File.html#listFiles(java.io.FileFilter)] for comparison. was: 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|http://java.sun.com/javase/6/docs/api/java/io/FileFilter.html]: {code} package org.apache.commons.net.ftp; public interface FTPFileFilter { public boolean accept(FTPFile file); } {code} A new method on FTPClient would need to be created to support it. Here's a code sample using API calls: {code} public FTPFile[] listFiles(FTPFileFilter filter) throws IOException { FTPFile files = listFIles(); List fileList = new ArrayList(files.length); for (FTPFile file : files) { if (filter.accept(file)) { fileList.add(file); } } return fileList.toArray(new FTPFile[fileList.size()]); } {code} See [java.io.File.listFiles(java.io.FileFilter)|http://java.sun.com/javase/6/docs/api/java/io/File.html#listFiles(java.io.FileFilter)] for comparison. Changed {{listFIles()}} to {{listFiles()}} in code sample. > Add a FTPClient.listFiles(FTPFileFilter) method > ----------------------------------------------- > > Key: NET-244 > URL: https://issues.apache.org/jira/browse/NET-244 > Project: Commons Net > Issue Type: New Feature > Affects Versions: 2.0 > Reporter: Matt Lachman > Priority: Minor > Attachments: NET-244.pat > > > 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|http://java.sun.com/javase/6/docs/api/java/io/FileFilter.html]: > {code} > package org.apache.commons.net.ftp; > public interface FTPFileFilter { > public boolean accept(FTPFile file); > } > {code} > A new method on FTPClient would need to be created to support it. Here's a code sample using API calls: > {code} > public FTPFile[] listFiles(FTPFileFilter filter) throws IOException { > FTPFile files = listFiles(); > List fileList = new ArrayList(files.length); > for (FTPFile file : files) { > if (filter.accept(file)) { > fileList.add(file); > } > } > return fileList.toArray(new FTPFile[fileList.size()]); > } > {code} > See [java.io.File.listFiles(java.io.FileFilter)|http://java.sun.com/javase/6/docs/api/java/io/File.html#listFiles(java.io.FileFilter)] for comparison. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.