-
Notifications
You must be signed in to change notification settings - Fork 3
/
bd.java
25 lines (17 loc) · 916 Bytes
/
bd.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
public class bd {
public static void main(String[] args) {
try {
String currentDirectory = System.getProperty("user.dir").toLowerCase();
currentDirectory = currentDirectory.substring(0, currentDirectory.lastIndexOf("\\") + 1); // Removing the current working directory from the path
String searchString = "\\" + args[0].toLowerCase().replaceAll("\"","");
int index = ("\\" + currentDirectory).lastIndexOf(searchString); // The back slash added at the start is to match the root if searched for
if ( index == -1 )
return;
System.out.print("\"" + currentDirectory.substring(0, currentDirectory.indexOf("\\",index)) + "\\\"");
}
catch ( Exception e )
{
// Exit without any error messages.
}
}
}