Home > Java > javaTutorial > body text

Java Example - Get file modification time

黄舟
Release: 2017-02-15 10:29:19
Original
1381 people have browsed it

The following example demonstrates using the file.lastModified() method of the File class to obtain the last modification time of the file

/*
 author by w3cschool.cc
 Main.java
 */import java.io.File;import java.util.Date;public class Main {
   public static void main(String[] args) {
      File file = new File("Main.java");
      Long lastModified = file.lastModified();
      Date date = new Date(lastModified);
      System.out.println(date);
   }}
Copy after login

The output result of running the above code is:

Thu Apr 09 09:40:19 CST 2015
Copy after login

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

Related labels:
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