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

Answered by stultuske 1,116 in a post from

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

Jump to Post
Answered by ~s.o.s~ 2,560 in a post from

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, …

Jump to Post

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, learning, and sharing knowledge.