PathUtils.java 327 B

123456789101112131415
  1. package org.ssssssss.magicapi.utils;
  2. import java.util.regex.Pattern;
  3. public class PathUtils {
  4. private static final Pattern REPLACE_SLASH_REGX = Pattern.compile("/+");
  5. /**
  6. * 将多个/替换为一个/
  7. */
  8. public static String replaceSlash(String path) {
  9. return REPLACE_SLASH_REGX.matcher(path).replaceAll("/");
  10. }
  11. }