This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 63232

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 ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: How to sort files based of creation of time,
It's not a secret anymore!