-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFileClass.java
42 lines (37 loc) · 1015 Bytes
/
FileClass.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package io;
import java.io.File;
/**
*
* @author chengfeili
* Jun 13, 2017 10:33:04 PM
*
*/
public class FileClass {
public void creat() {
System.out.println(java.io.File.separator); // /
File parent = new File("/home/smith");
File child = new File(parent, "data/zoo.txt");
}
public void fileObject() {
File file = new File("/usr/local");
System.out.println("File Exists: " + file.exists());
if (file.exists()) {
System.out.println("Absolute Path: " + file.getAbsolutePath());
System.out.println("Is Directory: " + file.isDirectory());
System.out.println("Parent Path: " + file.getParent());
if (file.isFile()) {
System.out.println("File size: " + file.length());
System.out.println("File LastModified: " + file.lastModified());
} else {
for (File subfile : file.listFiles()) {
System.out.println("\t" + subfile.getName());
}
}
}
}
public static void main(String[] args) {
FileClass fc = new FileClass();
fc.creat();
fc.fileObject();
}
}