21 lines
679 B
Java
21 lines
679 B
Java
|
|
package com.zhgd.xmgl.util;
|
||
|
|
|
||
|
|
public class PathUtil {
|
||
|
|
/**
|
||
|
|
* 删除多余的斜杠
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public static String reviseSlash(String path) {
|
||
|
|
return path.replaceAll("([^:])(//+)", "$1/");
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
System.out.println(reviseSlash("/home//foo/"));
|
||
|
|
System.out.println(reviseSlash("/home/foo/"));
|
||
|
|
System.out.println(reviseSlash("/homefoo//"));
|
||
|
|
System.out.println(reviseSlash("http://192.168.34.221:19111/xmgl/weight/weighInfo/getNewestWeighInfo"));
|
||
|
|
System.out.println(reviseSlash("http://192.168.34.221:19111/xmgl//weight/weighInfo/getNewestWeighInfo"));
|
||
|
|
}
|
||
|
|
}
|