athrunwang

          紀(jì)元
          數(shù)據(jù)加載中……

          我的評論

          String aPath = "/P/y/z/a/b/a/g/e.php";
          String bPath = "/P/y/z/a/b/a/g/c.php";
          情況的時(shí)候貌似不對。
          代碼可改成:
          public String pathARelativePathB(String pathA, String pathB, int i) {
          // A相對于B ../g/e.php
          if (pathA.contains(pathB)) {
          if (i == 1) {
          return pathA.replaceAll(pathB + "/", "");
          } else {
          StringBuffer sb = new StringBuffer();
          for (int j = 1; j < i; j++)
          sb.append("../");
          return sb.append(pathA.replaceAll(pathB + "/", "")).toString();
          }
          } else {
          return pathARelativePathB(pathA, pathB.substring(0, pathB.lastIndexOf("/")), ++i);
          }
          }
          非常好,幫了大忙了,十分感謝!
          主站蜘蛛池模板: 伽师县| 彝良县| 博罗县| 潍坊市| 明溪县| 雷州市| 定远县| 洛浦县| 永川市| 祁门县| 榆林市| 清丰县| 道真| 张家港市| 神木县| 闽清县| 通道| 东丰县| 南雄市| 子洲县| 阳城县| 葫芦岛市| 米易县| 修文县| 皮山县| 新和县| 麟游县| 峨边| 台中县| 于田县| 永登县| 天柱县| 常宁市| 大田县| 常州市| 拉萨市| 大悟县| 饶阳县| 福泉市| 中阳县| 普格县|