Hi is there a way of getting a file creation Date for a file class object?

I am trying to do so on a mac.

Many thanks

Recommended Answers

All 5 Replies

well...
since there are certain OS' that do not "remember" the creation date of a file, I doubht Java has a standard sollution for this.
At least not one I've come accross to

No, at least not when using the standard library because in *nix, the creation time isn't stored anywhere. If you are running on a windows box, you have two options:
- spawn a shell process which fires the command 'dir /a' and extract the creation time [easiest]
- Use JNI, maybe something like FileTimes library

If you are running on a windows box,

Windwos on a Mac? Blasphemy ;) :D

Ah, this is what I get for posting a reply based on the thread title. :-)

Many thanks for the replies.

I have tried this String creationDate = NativeInterface.nativeFileCreationDate(file.getAbsolutePath()); return creationDate; it then throws a : "java.lang.NoClassDefFoundError"

Is there any other means to do so on the mac or am I doing this wrong?

Many thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.