-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileTest.java
More file actions
42 lines (35 loc) · 1.12 KB
/
FileTest.java
File metadata and controls
42 lines (35 loc) · 1.12 KB
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 org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Date;
public class FileTest {
@Test
public void test(){
File file1 = new File("Hello.txt");
System.out.println(file1.getAbsoluteFile());
System.out.println(file1.getPath());
System.out.println(file1.getName());
System.out.println(file1.getParent());
System.out.println(file1.length());
System.out.println(new Date(file1.lastModified()));
System.out.println();
System.out.println(file1.isDirectory());
System.out.println(file1.isFile());
System.out.println(file1.exists());
System.out.println(file1.canRead());
System.out.println(file1.canWrite());
System.out.println(file1.isHidden());
}
@Test
public void test1() throws IOException {
File file2 = new File("hi.txt");
if(!(file2.exists())){
file2.createNewFile();
System.out.println("Create Successful");
}else {
file2.delete();
System.out.println("Delete Successful");
}
}
}