Because of different systems, the path information is different, but the final processing is in the same format,
For example: The input path is: D:\\kassdev\\app-kaace\\classes\\com\\kass\\commons\\utils,
The path information required for the output is: d:/kassdev/app-kaace/classes/com/kass/commons/utils
The following code, which deals with this situation
public static string Parsepath (final String path) {
if (Path==null | | path.length () ==0)
Return "";
if (path.indexof ("\ \") >=0) {
String path2 = Path.replaceall ("\\\\", "/");
while (Path2.indexof ("//") >=0) {
path2 = Path2.replaceall ("//", "/");
}
if (Path2.endswith ("/") &&!path2.equals ("/")) {
path2 = path2.substring (0, Path2.length ()-1);
}
return path2;
}else{
if (Path.indexof ("//") >=0) {
String path2 = Path.replaceall ("//", "/");
while (Path2.indexof ("//") >=0) {
path2 = Path2.replaceall ("//", "/");
}
if (Path2.endswith ("/") &&!path2.equals ("/")) {
path2 = path2.substring (0, Path2.length ()-1);
}
return path2;
}else{
if (Path.endswith ("/") &&!path.equals ("/")) {
String path2 = path.substring (0, Path.length ()-1);
return path2;
}else{
return path;
}
}
}
}
Normalize a path to prevent multiple '/' occurrences in a path, and prevent ' \ ' from appearing in the path, preventing the path from ending with '/'