-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMkdir.java
More file actions
60 lines (40 loc) · 1.52 KB
/
Mkdir.java
File metadata and controls
60 lines (40 loc) · 1.52 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
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.File;
public class Mkdir {
/* Command:
mkdir name
Action:
make a directory in the path of the name.
Errors:
The user enters:
1. dir The name is missing.
2. dir name But name is already exist.
When there is an error println a message and return (not exit).
*/
public Mkdir(String name){
f(name);
}
private static void f(String name){
//Initializing the File to null
File file = null;
// Initially the boolean is false
boolean bool = false;
// returns path names of files and directory
file = new File(name);
//Checking whether file path name is blank
if(name.length()==0){
// throwing error if the name is not entered
System.out.println("could not create the directory because the path name is not entered");
}
else {
// The file class creates a directory with a given name and updates bool
bool = file.mkdir();
// when the file is created the bool is changed
System.out.println("Directory created? " +bool);
// checking whether the bool is false
if(bool == false) {
// throwing error if it is false i.e the directory already exist
System.out.println("could not create the directory because the directory name already exist");
}
}
}
}