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) https://kodehelp.com All Rights Reserved.
 ****************************************************************************************/
package com.kodehelp.java.io;

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

/**
 * Created by Vigilance India.
 * User: https://kodehelp.com
 * 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);
        System.out.println(date);
    }
}

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.