/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(final String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
@Test public void testSeparatorsToWindows() { assertEquals(null, FilenameUtils.separatorsToWindows(null)); assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("\\a\\b\\c")); assertEquals("\\a\\b\\c.txt", FilenameUtils.separatorsToWindows("\\a\\b\\c.txt")); assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("\\a\\b/c")); assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("/a/b/c")); assertEquals("D:\\a\\b\\c", FilenameUtils.separatorsToWindows("D:/a/b/c")); }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath);
normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath);
/** * 把文件路径中的分隔符转换为window的格式,也就是"\" * * @param path * 文件完整路径 * @return 转换后的路径 */ public static String separatorsToWindows(String path) { return FilenameUtils.separatorsToWindows(path); }
public String normalize(final String path) { assert path != null; switch (platform) { case UNIX: return separatorsToUnix(path); case WINDOWS: return separatorsToWindows(path); default: throw new Error(); } }
public static String normalizeNoEndSeparator(String path, String separator) { String result = RelativeFilenameUtils.normalizeNoEndSeparator(path); // Undo the changes to the separators made by normalization if ("/".equals(separator)) { result = FilenameUtils.separatorsToUnix(result); } else if ("\\".equals(separator)) { result = FilenameUtils.separatorsToWindows(result); } else { throw new IllegalArgumentException("Unrecognised dir separator '" + separator + "'"); } return result; }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(final String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(final String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath);
normalizedBasePath = FilenameUtils.separatorsToUnix(normalizedBasePath); } else if (pathSeparator.equals("\\")) { normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath); } else { throw new IllegalArgumentException("Unrecognised dir separator '" + pathSeparator + "'");
normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath);
private static List<Matcher<Iterable<? super String>>> filesList(String... filenames) { List<Matcher<Iterable<? super String>>> result = new ArrayList<Matcher<Iterable<? super String>>>(); for (String current : filenames) { String filename = current.toString(); result.add(either(hasItem(filename)).or(hasItem(endsWith(separatorsToWindows(filename))))); } return result; }