[thelist] Getting a file's creation date in Java

Roger Ly evolt at matchpenalty.com
Wed Apr 2 16:38:47 CST 2003


We're building an application that reads in a bunch of files, and
displays them to the user sorted by its creation date.  Oldest files are
displayed first, etc.

Anyways, looking through the Java API, there doesn't seem to be a
getCreationDate() function for java.io.File.  There is a lastModified()
function which returns when the file was last modified.

Looking at Google, I saw a thread on Sun's site that says:

"i don't think u can get the file creation date as the file system
doesn't store the file creation date.  i suggest u to store the file
creation date inside the file if u need to do so."

http://forum.java.sun.com/thread.jsp?thread=361209&forum=31&message=1514
946

Is this true?  Do file systems not store date created?  I'm sure that
every OS I've ever dealt with has the ability to display both the last
modified date and the creation date of a file.

Has anyone ever come across this problem and found a way to get around
it?  The application is Java, but guaranteed to run on Win32, so I could
probably add some native hooks through JNI to get the information from
the OS, but I'd rather not do that if possible.

Thanks,

Roger



More information about the thelist mailing list