Jeremy, I don't know if this would help you but it might.

This example gets the last modified time of a file or directory and then
sets it to the current time.
    File file = new File("filename");

    // Get the last modified time
    long modifiedTime = file.lastModified();
    // 0L is returned if the file does not exist

    // Set the last modified time
    long newModifiedTime = System.currentTimeMillis();
    boolean success = file.setLastModified(newModifiedTime);
    if (!success) {
        // operation failed.
    }

Tom Kochanowicz
Nebraska Mental Ward
Head Janitor and part time java developer


-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED] On Behalf Of
Jeremy W. Redmond
Sent: Tuesday, July 15, 2003 2:39 PM
To: [EMAIL PROTECTED]
Subject: Changing a File's last_accessed_time from a servlet?

Ok... this may not exactly be a servlet-interest question, but I AM
trying to do this from a servlet, so I guess I can get away with the
question without getting flamed to bad.

I am trying to perform an action exactly like that of the UNIX "touch
-a" command.  However, I cannot actually run that command.  (That was my
first thought)  Our System Admin. does not want us to do any direct OS
commands.

Anyway, I know File.setLastModified() exists.  Is there anything that I
can set the last time that the file was accessed?

As to WHY I need to do this... when one of the servers in the cluster
fails over to another, it does not record the last time the file was
accessed.  Certain processes need to know this information.


Thanks in advance.

Jeremy Redmond
Java Developer
NYS Department Of Health

________________________________________________________________________
___
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to