import java.io.File;
import java.io.IOException;
import java.util.Date;
public class FileChange {
public static void main(String[] args) throws IOException {
File file = new File("copyfile");
file.createNewFile();
Date fileTime = new Date(file.lastModified()); //获取最后修改时间
System.out.println(fileTime.toString());
System.out.println(file.setLastModified(System.currentTimeMillis()));
fileTime= new Date(file.lastModified());
System.out.println(fileTime.toString());
}
}
![img_489ad54e6f83b5233a73bd9cc0022948.png](https://yqfile.alicdn.com/img_489ad54e6f83b5233a73bd9cc0022948.png?x-oss-process=image/resize,w_1400/format,webp)