-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattrib.java
More file actions
48 lines (37 loc) · 1.02 KB
/
attrib.java
File metadata and controls
48 lines (37 loc) · 1.02 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
43
44
45
46
import java.io.File;
public class Attrib extends Thread {
private String name;
public Attrib(String name) {
//creating a new object for the file class
this.name = name;
}
public void run()
{
//getName();
//creating a new object for the file class
File file = new File(name);
//if the file path name is blank
if(name.length()==0){
System.out.println("User does not type the file path name");
}
else{
//Checking whether the file exists or not
if(file.exists()){
//Checking whether the name is file or directory
if(file.isDirectory()){
//throwing error if the name is directory
System.out.println("could not make the file read only because it is a directory");
}
else {
//changing the file to read only mode
boolean readOnlyInd =file.setReadOnly();
System.out.println("Is this file readable (T/F)? " + readOnlyInd);
}
}
else{
//throwing error message if the file does not exists
System.out.println("The file does not exist");
}
}
}
}