How to get/retrieve Last Modified Date of File in Java?

Below java code example shoes how to get last modified date of file –

 * Created on 08-2011 Copyright(c) All Rights Reserved.

import java.util.Date;

 * Created by Vigilance India.
 * User:
 * Date: Aug 1, 2011
public class LastModifiedDateOfFile {
    public static void main(String args[]){
        File file = new File("/demo.txt");
        Long lastModifiedDate = file.lastModified();
        Date date = new Date(lastModifiedDate);

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.