My problem is not the runtime exception handling, that file exists and the
size of this array should be always 1, wherever i run my client.
Now if i run it on a Unix server the size is 1, if i run it from my
pc(wndows) i get an empty list.


2011/2/25 Martin Gainty <[email protected]>:
>
> FTPFile[] ftpFiles=ftpClient.listFiles(fileName);if(ftpFiles.length==0)
> {
> //ABORT!!!
> }
>
> Martin
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
> sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
> oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
> dem Austausch von Informationen und entfaltet keine rechtliche 
> Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen 
> wir keine Haftung fuer den Inhalt uebernehmen.
>
>
>
>
>
>
>> Date: Fri, 25 Feb 2011 10:10:29 +0000
>> Subject: Re: [Net] problem with listFiles(String pathname)
>> From: [email protected]
>> To: [email protected]
>> CC: [email protected]
>>
>> 2011/2/24 sebb <[email protected]>:
>> > On 24 February 2011 18:12, Francesco Fazzini <[email protected]> 
>> > wrote:
>> >> Dear all,
>> >>
>> >> i need to retrieve metadata informations(FTPFile) from a specific file.
>> >> This snippet of code I am using works fine in Unix, but not in my
>> >> local machine(Windows).
>> >
>> > Are you targeting the same ftp server?
>> > If not, are you sure they are serving the same files?
>>
>> Yes this client is targeting the same FTP server, and i am running the
>> client on two different OS. I tried also to connect to an another FTP
>> server(so also other files) to check if it was an issue related to a
>> specific FTP server but it is the same.
>>
>> >
>> >>         FTPClient ftpClient= new FTPClient();
>> >>         if(!workingDirectory.equals("")){
>> >>             ftpClient.changeWorkingDirectory(workingDirectory);
>> >>         }
>> >>         FTPFile[] ftpFiles= ftpClient.listFiles(fileName);
>> >>         Date lastModified= ftpFiles[0].getTimestamp().getTime();
>> >>
>> >>         //in the last line i get an ArrayIndexOutOfBoundsException
>> >> because "listFiles()" returns an empty array.
>> >
>> > That's because the code does not find any files that match.
>> >
>> >
>> >>         I tried to sort out in these ways below, but it doesn't work the 
>> >> same:
>> >>
>> >>         1)adding  "ftpClient.enterRemotePassiveMode();" just after
>> >> the fist line("FTPClient ftpClient= new FTPClient();").
>> >>
>> >>         2)adding "ftpClient.enterLocalPassiveMode();" just after the
>> >> first line("FTPClient ftpClient= new FTPClient();").
>> >>
>> >>         3)I tried also adding this configuration to the client:
>> >>
>> >>         FTPClient ftpClient= new FTPClient();
>> >>         FTPClientConfig config= new 
>> >> FTPClientConfig(FTPClientConfig.SYST_NT);
>> >>         ftpClient.configure(config);
>> >>         if(!workingDirectory.equals("")){
>> >>             ftpClient.changeWorkingDirectory(workingDirectory);
>> >>         }
>> >>         FTPFile[] ftpFiles= ftpClient.listFiles(fileName);
>> >>         Date lastModified= ftpFiles[0].getTimestamp().getTime();
>> >>
>> >> I would like it works with both environments, do you have any ideas?
>> >
>> > See above.
>> >
>> > Also, try adding control logging to the code:
>> >
>> >        ftpClient = new FTPClient();
>> >        ftpClient.addProtocolCommandListener(new PrintCommandListener(
>> >                                           new PrintWriter(System.out)));
>>
>> Additional LOG (working case Unix):
>>
>> CWD /pub/databases/files
>> 250 "/pub/databases/files" is new cwd.
>> SYST
>> 215 UNIX Type: L8
>> PORT 172,21,22,1,182,108
>> 200 PORT command successful.
>> LIST FILE_NAME
>> 150 Opening ASCII mode data connection for /bin/ls.
>> 226 Listing completed.
>>
>> Additional LOG (not working case Windows):
>> CWD /pub/databases/files
>> 250 "/pub/databases/files" is new cwd.
>> SYST
>> 215 UNIX Type: L8
>> PORT 172,22,69,22,193,11
>> 200 PORT command successful.
>> LIST FILE_NAME
>> 550 Cannot connect to {IP_ADDRESS} - timed out.
>> >
>> >> Thanks in advance.
>> >>
>> >> Regards,
>> >> Francesco
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to