tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > IO > Get Last Modified Date

Get Last Modified Date 

The following example shows how to access the last modified date of given file or directory.

File Name  :  
com/bethecoder/tutorials/io/LastModifiedTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.io;

import java.io.File;
import java.util.Date;

public class LastModifiedTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    File file = new File("C:\\file_ops.txt");
    System.out.println(file + " is last modified on " new Date(file.lastModified()));
    
    file = new File("C:\\Temp");
    System.out.println(file + " is last modified on " new Date(file.lastModified()));
  }

}
   

It gives the following output,
C:\file_ops.txt is last modified on Mon Apr 11 00:08:20 IST 2011
C:\Temp is last modified on Tue May 03 15:56:13 IST 2011



 
  


  
bl  br