Two Laptop Bag*
The moose likes I/O and Streams and the fly likes How to sort files based of creation of time, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to sort files based of creation of time," Watch "How to sort files based of creation of time," New topic

How to sort files based of creation of time,

sudhakar ananth
Ranch Hand

Joined: Feb 02, 2007
Posts: 68
Hello Friends

how to sort files based on creation time

1. how can we get the creation time of a file and how to sort based of creation like FIFO type
example a.txt 2.55 pm 2006
b.txt 3.07 am 2004
c.txt 1.04 pm 2007
e.txt 1.07 am 2004

so sorting should give e.txt,b.txt,a.txt and c.txt

so please tell me how to sort and where can get a method to get the sort or get the time of file...

please friends urgent..
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60822

Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Have you thought the possibility of using a java.util.Comparator?

Unfortunately I could find a method in the File class that tells me the creation time, but only the last modification time.

Then you can use it to sort list of files:

[ March 25, 2007: Message edited by: Edwin Dalorzo ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to sort files based of creation of time,
Similar Threads
creating jar file programatically
Commons net Ftpclient listfiles problem
how to delete an object from heap ?
Best data storage method
Multitread synchronization