importjava.net.URL;importjava.net.URLConnection;publicclassMain{publicstaticvoidmain(String[] argv)throwsException{URL u =newURL("http://127.0.0.1/java.bmp");URLConnection uc = u.openConnection();
uc.setUseCaches(false);long timestamp = uc.getLastModified();System.out.println("The last modification time of java.bmp is :"+timestamp);}}
结果
上面的代码示例将产生以下结果。
The last modification time of java.bmp is :24May200912:14:50
以下是检查文件是否在服务器上修改的示例。
importjava.net.URL;importjava.net.URLConnection;publicclassMain{publicstaticvoidmain(String[] argv)throwsException{URL u =newURL("https://www.cainiaoya.com/cpp_standard_library/cpp_fstream_close.htm");URLConnection uc = u.openConnection();
uc.setUseCaches(false);long timestamp = uc.getLastModified();System.out.println("The last modification time of file is :"+timestamp);}}
上面的代码示例将产生以下结果。
The last modification time of file is :1479867073000