forked from AndrewProgramming/JavaTutorialCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestFileClass.java
More file actions
20 lines (17 loc) · 804 Bytes
/
TestFileClass.java
File metadata and controls
20 lines (17 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package file;
import java.io.File;
public class TestFileClass {
public static void main(String[] args) {
File file = new File("test/andrew.txt");
System.out.println("Does it exists? " + file.exists());
System.out.println("The file has "+file.length()+" bytes");
System.out.println("Can it be read? "+file.canRead());
System.out.println("Can it be write? "+file.canWrite());
System.out.println("Is it a directory? "+file.isDirectory());
System.out.println("Is it a file? "+file.isFile());
System.out.println("Is it absolute? "+file.isAbsolute());
System.out.println("Is it hidden? "+file.isHidden());
System.out.println("Absolute path is ? "+file.getAbsolutePath());
System.out.println("Last modified on ? "+new java.util.Date(file.lastModified()));
}
}