📄 lastmodified.java
字号:
【代码7-3-2】
//LastModified.java
import java.io.*;
class LastModified
{
public static void main(String[] args)
{
try
{
File temp = File.createTempFile("jcl", ".out");
// Make sure it gets deleted when we're done
temp.deleteOnExit();
// Print out file name and its last modified time
long mod = temp.lastModified();
System.out.println(temp + ":" + mod);
// Introduced some delay
try
{
Thread.sleep(3000);
}
catch (InterruptedException ie)
{
};
// Write something out to file
FileWriter fout = new FileWriter(temp);
fout.write("hello");
fout.close();
System.out.println(temp + ":" + temp.lastModified());
// Change modified date back to original
if (temp.setLastModified(mod))
{
System.out.println(temp + ":" + temp.lastModified());
}
else
{
System.out.println("modification time unchanged");
}
//
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -