Java examples for File Path IO:File Attribute
Set last modified time of a file or directory
import java.io.*; import java.util.Date; public class Main { public static void main(String[] args) { //w ww . j a v a 2 s .co m File file = new File("C://Folder//ReadText.txt"); Date lastModified = new Date(file.lastModified()); System.out.println("Last modified time of file is : " + lastModified ); lastModified = new Date(); boolean blnSuccess = file.setLastModified(lastModified.getTime()); System.out.println("Was last modified time set successfully ?:" + blnSuccess); System.out.println("File last modification date is : " + new Date(file.lastModified())); } }