commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dell'Acqua, Carlo" <carlo.dellac...@siemens.com>
Subject R: How to filter remote file list ?
Date Wed, 23 Jul 2008 07:26:08 GMT
Thanks for your answer,
 
but using the method listFiles() i could obtain a lot of FTPFile and in this way it is possible
that I have memory problems.
 
Best Regards 

________________________________

Da: Rory Winston [mailto:rory.winston@gmail.com]
Inviato: mer 23/07/2008 1.17
A: Commons Developers List
Oggetto: Re: How to filter remote file list ?



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