commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rory Winston <rory.wins...@gmail.com>
Subject Re: How to filter remote file list ?
Date Tue, 22 Jul 2008 23:17:45 GMT
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


Mime
View raw message