Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 28794 invoked from network); 22 Jul 2008 23:16:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jul 2008 23:16:55 -0000 Received: (qmail 86511 invoked by uid 500); 22 Jul 2008 23:16:54 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 86438 invoked by uid 500); 22 Jul 2008 23:16:54 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 86427 invoked by uid 99); 22 Jul 2008 23:16:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 16:16:54 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rory.winston@gmail.com designates 64.233.182.190 as permitted sender) Received: from [64.233.182.190] (HELO nf-out-0910.google.com) (64.233.182.190) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 23:15:59 +0000 Received: by nf-out-0910.google.com with SMTP id e27so695937nfd.30 for ; Tue, 22 Jul 2008 16:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding:from; bh=GNuQF2vowJLEb+mjm83ubzpStPHXGeIGNHY0hApRWWo=; b=KLOjgAoXjheVx6dCuU3z3mQ6NoICjY20hZC3S2LpvmyL+UEC263bbJN7Ysm94HlBeO 66ELbRaHxiinLkhtdGbd80u5u94kzpV/lAe6SfcyI15O9bogl+NlBU2FAfWevs/pi0A5 aY/s8rY3WaTSGOpPU41mxKB78UYF/SHIzAOn4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding:from; b=gK/KQUQQDhcrg/mfzJCPG/ynt/FVMSWvuaxsN0h0iRxRGJUXtp1LJBQWIEUT8K0mN3 RIYG2RgAED9JvPDZ7e5yaBjTaUoiUUDoXqVr5afqBvJJTk1QorLYE2XzMFxdUKXQjUFK iecC12gFbLwsY+Uuit7j9TLDCb0tZj1zECiR0= Received: by 10.210.126.18 with SMTP id y18mr5124540ebc.97.1216768583156; Tue, 22 Jul 2008 16:16:23 -0700 (PDT) Received: from ?192.168.0.2? ( [90.192.58.238]) by mx.google.com with ESMTPS id u14sm6298019gvf.6.2008.07.22.16.16.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 22 Jul 2008 16:16:22 -0700 (PDT) Message-ID: <48866A99.5090801@eircom.net> Date: Wed, 23 Jul 2008 00:17:45 +0100 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Commons Developers List Subject: Re: How to filter remote file list ? References: <9159F40A3C554742AE8BDEB25B464E7A61C8CC@MILVB534A.it001.siemens.net> In-Reply-To: <9159F40A3C554742AE8BDEB25B464E7A61C8CC@MILVB534A.it001.siemens.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Rory Winston X-Virus-Checked: Checked by ClamAV on apache.org Carlo Depending on the server, using a glob expression in listFiles() ftpcl.listFiles("*.foo") may work, although it is not guaranteed. Rory Dell'Acqua, Carlo wrote: > Hello, > > I'm using FTPClient to access a remote FTP server and get a subset of > files contained into its directory, the following is an exctract from my > code: > > FTPClient ftpcl = new FTPClient(); > > ftpcl.connect(remotehost); > if(!FTPReply.isPositiveCompletion(ftpcl.getReplyCode())) { > // ERROR > } > > if(!ftpcl.login(remoteuser, remotepassword)) { > // ERROR > } > > ftpcl.noop(); > > if(!ftpcl.changeWorkingDirectory(remotedir)) { > // ERROR > } > > FTPListParseEngine engine = ftpcl.initiateListParsing(); > > while (engine.hasNext()) { > FTPFile[] files = engine.getNext(50); > > for(FTPFile file : files) { > if(fileOK(file)) { > FileOutputStream fos = new FileOutputStream( dst ); > if(!ftpcl.retrieveFile( file.getName(), fos )) { > // ERROR > } > } > } > } > > The problem is that on remote directory there are a lot of files that I > don't need to download (they have a different file name from the file I > need to download); until now I have used my method fileOK(FTPFile) to > check each file returned by initiateListParsing(); > so my question is: is it possible to filter the file returned by > initiateListParsing() using a regular expression ? > > Thanks in advance and Best Regards. > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org