HOME      BLOG       FORUMS      CONTACT       ABOUT

Finds the last modified date of a file or directory.

Finds the last modified date of a file or directory.

The lastModified method of file class can be used for finding the last modified date of a file or directory.

package io;

import java.io.File;
import java.util.Date;

public class FileExample {
	public static void main(String[] args){
		File file = new File("d:\\temp\\test.txt");

		// Find the last modified date
		long value = file.lastModified();

		// Convert the value to date
		Date lastModifiedDate = new Date(value);
		System.out.println(lastModifiedDate);
	}
}

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