Reputation: 2200
I need to get file creation date in linux machine using java. Many workarounds worked good in windows but failed in linux. Need a way to get file creation time in linux. Please note that my linux machine has java6 installed. Any help is much appreciated. Thanks in adavance.
Upvotes: 2
Views: 4821
Reputation: 785058
You can use stat
command in Linux to get various date though creation date isn't available.
Instead you can get these 3 dates about a file:
EDIT:
For getting creation/modification times of a file in Java (if using JDK 1.7) see: http://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html
As per this document:
A word about time stamps: The set of basic attributes includes three time stamps: creationTime, lastModifiedTime, and lastAccessTime. Any of these time stamps might not be supported in a particular implementation, in which case the corresponding accessor method returns an implementation-specific value.
Unfortunately Linux/Unix doesn't store file's creation time hence you cannot get it.
PS: If you can use ext4 filesystem
then you can get file's creation time in Unix/Linux.
Upvotes: 2