Sample Programs

Sample java program to set modified time of file

 package org.jusfortechies.example; 

 import java.io.File;
 
 public class FileModifiedTime {

   public static void main(String[] args) {
     
	 File file = new File("C:\\samplefile.txt");
			
	 // Set the last modified time
	 long newModifiedTime = System.currentTimeMillis();

	 boolean success = file.setLastModified(newModifiedTime);
	 if (!success) {
	   System.out.println("Failed to set the modified time");
	 }
	
   }

 }




blog comments powered by Disqus