Cache Pattern instance

This commit is contained in:
Reinhard Pointner 2016-02-22 04:34:08 +00:00
parent c41f564832
commit 158119a26b
1 changed files with 3 additions and 1 deletions

View File

@ -620,12 +620,14 @@ public final class FileUtilities {
return path.replace('\\', '/');
}
private static final Pattern PATH_SEPARATORS = Pattern.compile("\\s*[\\\\/]+\\s*");
public static String replacePathSeparators(CharSequence path) {
return replacePathSeparators(path, " ");
}
public static String replacePathSeparators(CharSequence path, String replacement) {
return Pattern.compile("\\s*[\\\\/]+\\s*").matcher(path).replaceAll(replacement);
return PATH_SEPARATORS.matcher(path).replaceAll(replacement);
}
public static String md5(String string) {