File LastModified() Example
Returns the time that the file denoted by this abstract pathname was last modified.
File class LastModified() method example. This example shows you how to use LastModified method.This method Returns the time that the file denoted by this abstract pathname was last modified.
Here is the code:-
/**
* @Program that Returns the time that the file denoted by this abstract
* pathname was last modified.
* LastModified.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
import java.util.*;
public class LastModified {
public static void main(String[] args) {
File f = new File("/home/girish/Desktop/g.txt");
if (f.exists()) {
long l = f.lastModified();
Date d = new Date(l);
System.out.println("file was last modified : " + d);
} else {
System.out.println("File does not exists");
}
}
} |
Output of the Program
| file was last modified : Fri May 30 16:48:02 IST 2008 |
|