Is it possible to get a file's creation date in Java?

Byron Tymvios

It is not possible to obtain this information on *nix machines since this information is not stored about the files, only file modification date is stored. Therefore java has no methods for obtaining this information, probably due to it's "write once, run everywhere" policy.

On Windows machines this information is stored, but as said earlier there are no java methods for obtaining it.

Solutions to this problem could be:
-To write a jni app that can retrieve the creation date and pass the value back to Java. (Windows machines only).
-Use Runtime/ProcessBuilder class to execute a operating system process (namely 'dir' on Windows), retrieve the output and parse it to get the values. (Windows machines only).
-To store the date somewhere, such as the in the file itself or in a database (requires a custom application to insert the value and files cannpt be created outside of this process).

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact