Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Apr 5, 1999

Modifying File Timestamp

Question:
Is there any way to change a file's last modification time from Java?

Answer:
It is not possible to alter the time of last modification in Java version before the 1.2 JDK. One of the new features introduced to java.io.File in the Java 2 Platform is the ability to reset the last modified time. Your question is an example of a situation that Java programmers face constantly. With each new Java release, many major features are introduced, but many minor changes also creep in, making it difficult to stay on top of all of the APIs.

Back to your question: all you have to do is call setLastModified(long time). The time argument should be a time measured in milliseconds since midnight GMT, January 1, 1970. The method will return true if it can set the time, false if it cannot.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date