commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Fazzini <ffrancesc...@gmail.com>
Subject [Net] problem with listFiles(String pathname)
Date Thu, 24 Feb 2011 18:12:59 GMT
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).

         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.

         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?
Thanks in advance.

Regards,
Francesco

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message