HOME      BLOG       FORUMS      CONTACT       ABOUT

Change the last modified date of a file or directory.

Change the last modified date of a file or directory.

The setLastModified method of file class can be used for changing the last modified time of a directory or a file.

import java.io.File;
import java.util.Date;
/**
 * File class examples
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Get the current time
		long time = new Date().getTime();

		// Change the last modified time.
		file.setLastModified(time);
	}
}

Share

Tags: , , , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply