Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Getting folder contents - date wise sorted ?

  Asked By: Lydia    Date: May 07    Category: Java    Views: 7858
  

I wish to get file/ folder names within a folder sorted in ascending
order by date. If I write:

//...example code....

File tmpFolder = new Folder("c:/temp");
String allFiles[] = tmpFolder.list(); // getting contents

// ... end of code ...

here allFiles[] would have code in any order as specs says, not
necessarily in any order. Any suggestions?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Julia Hughes     Answered On: May 07


Well, list() will give you the array as you've shown. Add the elements of that
array to a List. Then, what I would do is create a Comparator that operates on
File objects. This comparator uses the date  to determine if one object is less
than another. Then use Collections.sort(List, Comparator). That's it.

 
Answer #2    Answered By: Scarlett Hughes     Answered On: May 07

i was having a problem in understanding and testing the SNMP trap mechanism

if any body can give me an example  of how to test the traps eg recieving traps
on my own machine(generating traps for it) and testing and using trap mechanism

if any body has an idea please rply me

 
Didn't find what you were looking for? Find more on Getting folder contents - date wise sorted ? Or get search suggestion and latest updates.




Tagged: