Link to home
Start Free TrialLog in
Avatar of choks
choks

asked on

file access time

how can i get the time a file was last accessed?sorry about the low points, its all i got left.
Avatar of cs_csm
cs_csm

Reference code is as follow:

import java.io.*;
import java.util.*;

class test {
    public test() {}

    public static void main(String[]args) {
     File file = new File(args[0]);
     Date date = new Date(file.lastModified());
               
    //this print the last modified time of a file
    System.out.println(date.toString());

   }
}
Note, there is a difference between modified and accessed, I can access a file without changing the modified time!
Avatar of choks

ASKER

I dont need the last modified date......i need the last accessed date.
ASKER CERTIFIED SOLUTION
Avatar of diakov
diakov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of choks

ASKER

Comment accepted as answer
Avatar of choks

ASKER

Comment accepted as answer