-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJPRemove.java
More file actions
37 lines (32 loc) · 819 Bytes
/
Copy pathJPRemove.java
File metadata and controls
37 lines (32 loc) · 819 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
35
36
37
//removes directory from hash in case it's been deleted
public class JPRemove{
public void remove(String k){
String key = truncate(k);
JPConstructor io = new JPConstructor();
HashTableChained hash = io.retrieveTable();
hash.remove(key);
io.storeTable(hash);
}
public String truncate(String x){
String k = x;
for(int i = k.length()-1; i >= 0; i--){
char letter = k.charAt(i);
//if the last letter is / , cut it out
if((letter=='/' || letter == ' ') && i==k.length()-1){
k = k.substring(0, i);
i = k.length();
continue;
}
if( letter=='/' && i!=k.length()-1){
k = k.substring(i+1);
return k;
}
}
return k;
}
public static void main(String[] args){
String key = args[0];
JPRemove remover = new JPRemove();
remover.remove(key);
}
}