PathUtils { public static String normalizeSeparators(String input) { if(input == null || input.length() == 0) return ""; int len = input.length(); int n = len; while ((n > 0) && (input.charAt(n - 1) == '/')) n--; if (n == 0) return "/"; StringBuilder sb = new StringBuilder(input.length()); char prevChar = 0; for (int i=0; i < n; i++) { char c = input.charAt(i); if ((c == '/') && (prevChar == '/')) continue; checkValidChar(input, c); sb.append(c); prevChar = c; } return sb.toString(); }  static String normalize(String path); static String getFileName(String path); static String getParentPath(String path); static String getFileName(String path, int[] offsets); static String subpath(String path, int beginIndex, int endIndex); static String absoluteSubpath(String path, int endIndex, int[] offsets); static String subpath(String path, int beginIndex, int endIndex, int[] offsets); static String getParentPath(String path, int[] offsets); static String resolve(String base, String child); static int[] offsets(String path); static boolean isAbsolute(String path); static String normalize(String path, int[] offsets); static String normalizeSeparators(String input); static String normalizeRegex(String pathPattern);  }
@Test public void testNormalizeAndCheck(){ System.out.println("normalized and check test"); System.out.println(PathUtils.normalizeSeparators("/abc/def/")); System.out.println(PathUtils.normalizeSeparators(" System.out.println(PathUtils.normalizeSeparators(" }