Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java Example – Getting the Last Modified Time of a Directory

Java Example – Getting the Last Modified Time of a Directory

Java Examples Java Examples

The following example demonstrates using the file.lastModified() method of the File class to get the last modified time of the directory:

Main.java File

import

java

.

io

.

File

;

import

java

.

util

.

Date

;

public

class

Main

{

public

static

void

main

(

String

[

]

args

)

{

File

file

=

new

File

(

"

C://FileIO//demo.txt

"

)

;

System

.

out

.

println

(

"

Last modified time:

"

new

Date

(

file

.

lastModified

(

)

)

)

;

}

}

The output of the above code is:


最后修改时间:Fri Apr 10 11:09:19 CST 2015

Java Examples Java Examples