The Artima Developer Community
Sponsored Link

Java Answers Forum
File Properties

3 replies on 1 page. Most recent reply: Apr 2, 2003 4:38 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Bruce Jacobs

Posts: 4
Nickname: comet304
Registered: Apr, 2003

File Properties Posted: Apr 2, 2003 10:22 AM
Reply to this message Reply
Advertisement
Using Java code how can I get the date and time stamp from a file (properties). All the files in a folder have a create and/or modify date, how can I access this so I can interrogate it?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: File Properties Posted: Apr 2, 2003 11:18 AM
Reply to this message Reply
You can get the lastModified date from the File object. I don't know about the created date...

If all else fails, a little RMI object could do the trick by calling the Windows API.

Or a really ugly trick would be to do a Runtime.exec() on "cmd /c dir d:\\path\\filespec >%temp%\fileinfo.txt" and then parse fileinfo.txt...

It would be nice if the Java API included some simple support for COM, such that you could use Dispatch. Then you could use the Windows Script Host objects (WScript.Shell, Scripting.FileSystemObject, and so on). This would solve a lot of these Windows-specific questions, without really causing Java to be platform dependent (you try to get an object with Dispatch, if the platform doesn't support it you get null). Unfortunately Sun and Microsoft are arch enemies, so such practicality is irrelevant.

Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: File Properties Posted: Apr 2, 2003 3:02 PM
Reply to this message Reply
What does "a little RMI object" has to do with getting file creation date?????

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: File Properties Posted: Apr 2, 2003 4:38 PM
Reply to this message Reply
Oops, I meant JNI.

Flat View: This topic has 3 replies on 1 page
Topic: String and arrays Previous Topic   Next Topic Topic: Getting the Most out of a J2EE platform

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use