Get Last modification time of a file or directory - Java File Path IO

Java examples for File Path IO:File Attribute

Description

Get Last modification time of a file or directory

Demo Code


import java.io.*;
import java.util.Date;
 
public class Main {
 
  public static void main(String[] args) {
   //w ww. j  av  a 2s .c  o m
    //create file object
    File file = new File("C://Folder//demo.txt");
   
     long lastModified = file.lastModified();
   
     System.out.println("File was last modifed at : " + new Date(lastModified));
  }
}

Result


Related Tutorials