-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileClassExample.java
31 lines (24 loc) · 994 Bytes
/
FileClassExample.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
import java.io.*;
public class FileClassExample {
public static void main(String[] args) throws IOException {
File f1 = new File("../Java/temp.txt");
if (f1.exists())
System.out.println("File exists.");
else
System.out.println("File does not exist.");
// Creating the file
if (f1.createNewFile())
System.out.println("File created!");
if (f1.exists())
System.out.println("File exists.");
else
System.out.println("File does not exists");
System.out.println("File Writing Permission : " + f1.canWrite());
System.out.println("File Reading Permission : " + f1.canWrite());
System.out.println("File Execution Permission : " + f1.canWrite());
System.out.println("Name of File : " + f1.getName());
System.out.println("Length of File : " + f1.length());
if (f1.delete())
System.out.println("File deleted!");
}
}