Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commons net Ftpclient listfiles problem

 
Ramesh Nuthalapati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

.
..
a.txt
b.txt
c.txt
d.txt

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
 
Ramesh Nuthalapati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a hack by refiltering the files by excluding . and .. and kept the rest of files into another ftpfiles[].

That solved for now.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic