-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRename.java
More file actions
34 lines (27 loc) · 885 Bytes
/
Rename.java
File metadata and controls
34 lines (27 loc) · 885 Bytes
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
public class Rename {
/* Command:
rename nameA nameB
Action:
Renames the file nameA to the file nameB.
Use your classes Copy and Delete for this.
Errors:
The user enters:
1. rename The names nameA and nameB are missing.
When there is an error println a message and return (not exit).
*/
public Rename(String name) {
f(name);
}
private String[] f(String name) {
//copy class is called to copy the contents to the new name file
Copy.f(name);
System.out.println(name);
// now Split the paths to delete the old name file
String[] names = name.split(" ");
//Deleting the old name
Delete.f(names[0]);
// Prints the renamed file path
System.out.println("The Renamed file is: " + names[1]);
return null;
}
}