Java 实例 - 查看主机指定文件的最后修改时间
Java 教程
· 2019-02-11 21:12:06
以下实例演示了如何查看主机指定文件的最后修改时间:
Main.java 文件
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Main {
public static void main(String[] argv) throws Exception {
URL u = new URL("http://127.0.0.1/test/test.html");
URLConnection uc = u.openConnection();
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
uc.setUseCaches(false);
long timestamp = uc.getLastModified();
System.out.println("test.html 文件最后修改时间 :" + ft.format(new Date(timestamp)));
}
}
以上代码运行输出结果为:
test.html 文件最后修改时间 :2018-09-06 10:06:04
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
JavaScript Patterns
Stoyan Stefanov / O'Reilly Media, Inc. / 2010-09-21 / USD 29.99
What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced d......一起来看看 《JavaScript Patterns》 这本书的介绍吧!