aspose file tools
The moose likes Java in General and the fly likes How to know when was th e file open/modified Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to know when was th e file open/modified" Watch "How to know when was th e file open/modified" New topic
Author

How to know when was th e file open/modified

pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
hi

How can i know when was the file opened /modified in java

Thx in Advance
Pankaj


Regards,
Pankaj Patil
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24054
    
  13

By using the lastModified() method in java.io.File .


[Jess in Action][AskingGoodQuestions]
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
You can use lastModified() method in java.io.File class to get the time at which the file was last modified.
But you cannot get the time at which the file was last accessed / opened using java API.


Mani
Quaerendo Invenietis
pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
Thx for the reply .

there r no java API which can tell me when was the file opened .

is there any way by which i can restrict the file to be get opened.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24054
    
  13

There's no Java API that reports when a file was last accessed because not all operating systems can tell you the needed information: UNIX can, but I don't think Windows can.

Likewise, there's not much of an API for file protection in Java because, again, not all OSs support that idea. There is a method setReadOnly() in java.io.File that lets you mark a file as read-only, but that's about it.
pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
thanks for reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know when was th e file open/modified
 
Similar Threads
How to know when a file was last modified
external js
how to get LastModified time of a file in repository(in weblogic8.2 )
last modified date of a file
how to get the last modified time of a text file