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);
}
}
Tags: File, file class examples, File examples, java.io, java.io.File
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.
Leave a Reply