### Question:
SmartFile { public static String sanitizePaths(String pathsString) { if (!ok(pathsString)) return pathsString; try { String[] paths = pathsString.split(File.pathSeparator); StringBuilder sb = new StringBuilder(); Set<String> pathsSet = new HashSet<String>(); List<String> pathsList = new LinkedList<String>(); for (String path : paths) { if (!ok(path)) continue; path = SmartFile.sanitize(path); if (pathsSet.add(path)) pathsList.add(path); } boolean firstElement = true; for (String path : pathsList) { if (firstElement) firstElement = false; else sb.append(File.pathSeparator); sb.append(path); } return sb.toString(); } catch (Exception e) { return pathsString; } } private  SmartFile(File f); private  SmartFile(String s); static File sanitize(File f); static String sanitize(String filename); static String sanitizePaths(String pathsString);  }### Answer:
@Test public void sanitizePaths() { String sep = File.pathSeparator; String here = SmartFile.sanitize("."); String cp1before = "/a/b/c" + sep + "qqq" + sep + "qqq" + sep + "qqq" + sep + "qqq" + sep + "qqq" + sep + "./././qqq/./." + sep + "z/e"; String cp1expected = "/a/b/c" + sep + here + "/qqq" + sep + here + "/z/e"; if (sep.equals(";")) { String drive = here.substring(0, 2); cp1expected = drive + "/a/b/c;" + here + "/qqq;" + here + "/z/e"; } assertEquals(cp1expected, SmartFile.sanitizePaths(cp1before)); }
@Test public void sanitizePaths2() { String sep = File.pathSeparator; if (OS.isWindows()) { String badPaths = "c:/xyz;\"c:\\a b\";c:\\foo"; String convert = SmartFile.sanitizePaths(badPaths); String expect = "C:/xyz;C:/a b;C:/foo"; assertEquals(convert, expect); } else { String badPaths = "/xyz:\"/a b\":/foo"; String convert = SmartFile.sanitizePaths(badPaths); String expect = "/xyz:/a b:/foo"; assertEquals(convert, expect); } }