Java File.setLastModified(long time)
Syntax
File.setLastModified(long time) has the following syntax.
public boolean setLastModified(long time)
Example
In the following code shows how to use File.setLastModified(long time) method.
/*ww w.j a va 2s . com*/
import java.io.File;
import java.util.Date;
public class Main {
public static void main(String[] args) {
File f = new File("C:/test.txt");
long millisec = new Date().getTime();
// set last modified time
boolean bool = f.setLastModified(millisec);
System.out.println("lastModified() succeeded?: " + bool);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »