File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Commons net Ftpclient listfiles problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Commons net Ftpclient listfiles problem" Watch "Commons net Ftpclient listfiles problem" New topic

Commons net Ftpclient listfiles problem

Ramesh Nuthalapati

Joined: Mar 04, 2009
Posts: 4
Hi, i am having an issue with ftpClient.listFiles method.

files = ftpClient.listFiles(ftpFolderName); -- returns all the files in the folder

fileNames = ftpClient.listNames(); -- list all file names in the folder

Lets say i have files name in the folder as


listfiles loaded everything in the directory.

I need timestamp of all txt files, so what i had done is trying to get timestamp of FTPFiles.getTimestamp of first element which gives me "." (dir) timestamp.

listNames gives the index as 4. when I get timestamp on index 0 then its "." timestamp. where as when i do files[i].getName with index 0 it shows a.txt which is correct.

How do i tell listFiles not to include . and .. folders in code ?

Thanks for your help.
Ramesh Nuthalapati

Joined: Mar 04, 2009
Posts: 4
I did a hack by refiltering the files by excluding . and .. and kept the rest of files into another ftpfiles[].

That solved for now.

I agree. Here's the link:
subject: Commons net Ftpclient listfiles problem
jQuery in Action, 3rd edition