StringUtils { public static String cleanPath(String path) { if (path == null) { return null; } String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR); int prefixIndex = pathToUse.indexOf(":"); String prefix = ""; if (prefixIndex != -1) { prefix = pathToUse.substring(0, prefixIndex + 1); if (prefix.contains("/")) { prefix = ""; } else { pathToUse = pathToUse.substring(prefixIndex + 1); } } if (pathToUse.startsWith(FOLDER_SEPARATOR)) { prefix = prefix + FOLDER_SEPARATOR; pathToUse = pathToUse.substring(1); } String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR); List<String> pathElements = new LinkedList<String>(); int tops = 0; for (int i = pathArray.length - 1; i >= 0; i--) { String element = pathArray[i]; if (CURRENT_PATH.equals(element)) { } else if (TOP_PATH.equals(element)) { tops++; } else { if (tops > 0) { tops--; } else { pathElements.add(0, element); } } } for (int i = 0; i < tops; i++) { pathElements.add(0, TOP_PATH); } return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR); }  static boolean isBlank(String str); static boolean isNotBlank(String str); static String mapToStringWithPrefix(Map<String, String> map, String prefix); static String mapToString(Map<String, String> map); static void stringToMap(String str, Map<String, String> map); static String escapeComma(String str); static String unescapeComma(String str); static String arrayToString(Object[] items, char separator, String prefix, String postfix); static String escapePercentEqualAnd(String str); static String unescapeEqualAndPercent(String str); static boolean hasText(CharSequence str); static String cleanPath(String path); static String collectionToDelimitedString(Collection<?> coll, String delim); static String collectionToDelimitedString(Collection<?> coll, String delim,
                                                     String prefix, String suffix); static String[] delimitedListToStringArray(String str, String delimiter); static String[] delimitedListToStringArray(String str, String delimiter,
                                                      String charsToDelete); static String[] toStringArray(Collection<String> collection); static String deleteAny(String inString, String charsToDelete); static String replace(String inString, String oldPattern, String newPattern); static int countMatches(String str, char c); static final String NEWLINE; static final String EMPTY_STRING; static final String EQUAL; static final String AND; static final char EQUAL_CHARACTER; static final char AND_CHARACTER; static final String[] EMPTY_STRING_ARRAY; }
@Test public void testCleanPath() throws Exception { }