It's not a secret anymore!*
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 Murach's Java Servlets and JSP this week in the Servlets 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.

subject: Commons net Ftpclient listfiles problem
Similar Threads
creating jar file programatically
Getting A File List From A Directory
How i can get Folder Explorer
reading a dynamic file...
About deleting files using listFiles()