file lastModified Example
file class lastModified example. This example shows you how to use lastModified method.
File class lastModified example. method long datatype values as time for the specified abstract pathname file last modified or formatted.path is abstract as it is defined inside the system.method is called through a long type variable.this time is returned in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
Here is the code:-
/**
* @Program uses lastModified method to check the time of the abstract
* pathname file last modified.
* LastModified.java
* Author:-RoseIndia Team
* Date:-30-june-2008
*/
import java.io.*;
public class LastModified {
public static void main(String args[]) throws IOException {
File alice = new File("/home/mahendra/Desktop/x.txt");
long time_in_miliseconds = alice.lastModified(), time_in_seconds = alice
.lastModified() / 1000;
System.out.println("last modified time in milliseconds and seconds");
System.out.println("time_in_miliseconds: " + time_in_miliseconds
+ "\n" + "time_in_seconds: " + time_in_seconds);
}
} |
Output of the program:-
last modified time in milliseconds and seconds
time_in_milliseconds: 1215018239000
time_in_seconds: 1215018239 |
|