tia_kamakshi
asked on
FInding file age in Java
Hi,
How do we check in Java that file age is more than 10 min or 5 min
Please guide
Many Thanks
How do we check in Java that file age is more than 10 min or 5 min
Please guide
Many Thanks
What do you mean by age? If you mean when it was created, that's not possible to know via Java - not every OS has a record of when a file was created
you can't get a files creation date with java so you'll need to use exec() of jni to do that
if you mean since it was last modified then use
long age = new Date().getTime() - file.lastModified();
long age = new Date().getTime() - file.lastModified();
ASKER
Hi,
Thanks for your responses.
I wanted to know the age of file, means when it was created or modified and the current time.
How many minutes, or hours has passed from the current time
Yes, this will help me
long age = new Date().getTime() - file.lastModified();
But I wanted to know the time in minutes.
Becuase there is a directory where XML file should not be present in there more than 5 min.
Some file should not be present there for more than 10 min
If file stays there in the directory than alert mail and sms needs to be sent immedieately
So, I wanted the minutes passed from the time file is created in the system or modified in the system.
I am very thankful to you and EE for providing great help
Thanks again
Thanks for your responses.
I wanted to know the age of file, means when it was created or modified and the current time.
How many minutes, or hours has passed from the current time
Yes, this will help me
long age = new Date().getTime() - file.lastModified();
But I wanted to know the time in minutes.
Becuase there is a directory where XML file should not be present in there more than 5 min.
Some file should not be present there for more than 10 min
If file stays there in the directory than alert mail and sms needs to be sent immedieately
So, I wanted the minutes passed from the time file is created in the system or modified in the system.
I am very thankful to you and EE for providing great help
Thanks again
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many Thanks.
I will check and come back to you.
Thanks again
I will check and come back to you.
Thanks again
ASKER
Many Thanks