Home  >  Article  >  Java  >  Java Example - View the last modification time of a specified file on the host

Java Example - View the last modification time of a specified file on the host

黄舟
黄舟Original
2017-01-20 11:55:141465browse

The following example demonstrates how to view the last modification time of the file specified by the host:

/*
 author by w3cschool.cc
 Main.java
 */import java.net.URL;import java.net.URLConnection;public class Main {
   public static void main(String[] argv) 
   throws Exception {
      URL u = new URL("http://127.0.0.1/java.bmp");
      URLConnection uc = u.openConnection();
      uc.setUseCaches(false);
      long timestamp = uc.getLastModified();
      System.out.println("java.bmp 文件最后修改时间 :"+timestamp);
   }}

The output result of running the above code is:

java.bmp 文件最后修改时间 24 May 2014 12:14:50

The above is the Java example - View The content of the last modification time of the file specified by the host. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn