Browse Source

修改linux路径问题

wangyanygang 4 years ago
parent
commit
f1625b2064
1 changed files with 8 additions and 6 deletions
  1. 8 6
      user_center/src/main/java/com/huaxu/common/ToolUtil.java

+ 8 - 6
user_center/src/main/java/com/huaxu/common/ToolUtil.java

@@ -236,18 +236,20 @@ public class ToolUtil {
      * @param path 待修正的路径
      * @return 修正后的路径
      */
-    public static String path(String path){
+    public static String path(String path) {
         String p = StringUtils.replace(path, "\\", "/");
         p = StringUtils.join(StringUtils.split(p, "/"), "/");
-        if (!StringUtils.startsWithAny(p, "/") && StringUtils.startsWithAny(path, "\\", "/")){
+        if (!StringUtils.startsWithAny(p, "/") && StringUtils.startsWithAny(path, "\\", "/")) {
             p += "/";
         }
-        if (!StringUtils.endsWithAny(p, "/") && StringUtils.endsWithAny(path, "\\", "/")){
-            p = p + "/";
-        }
-        if (path != null && path.startsWith("/")){
+//        if (!StringUtils.endsWithAny(p, "/") && StringUtils.endsWithAny(path, "\\", "/")) {
+//            p = p;//+ "/";
+//        }
+        if (path != null && path.startsWith("/")) {
             p = "/" + p; // linux下路径
         }
+
+
         return p;
     }