Java Program to Get Last Modified Time of File in Command Line

Java Program to Get Last Modified Time of File in Command Line

import java.io.File;
import java.util.Date;
 
public class Example7 {
       public static void main(String[] args) {
       File file = new File("test.txt");
       Date date=new Date(file.lastModified());
   System.out.println("\nThe file was last modified on: "+date+"\n");   
     }
}

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment