forked from DuHouAn/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileDemo6.java
More file actions
26 lines (22 loc) · 821 Bytes
/
FileDemo6.java
File metadata and controls
26 lines (22 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package code_00_disk;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by 18351 on 2019/1/4.
*/
public class FileDemo6 {
public static void main(String[] args) {
// 创建文件对象
File file = new File("demo2\\a.txt");
System.out.println("getAbsolutePath:" + file.getAbsolutePath());
System.out.println("getPath:" + file.getPath());
System.out.println("getName:" + file.getName());
System.out.println("length:" + file.length());
System.out.println("lastModified:" + file.lastModified());//lastModified:1546584213001
Date d = new Date(1546584213001L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = sdf.format(d);
System.out.println(s);
}
}