Home > Java > javaTutorial > body text

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

黄舟
Release: 2017-01-20 11:55:14
Original
1479 people have browsed it

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);
   }}
Copy after login

The output result of running the above code is:

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

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)!


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template