List of utility methods to do Path String Clean
String | cleanPath(String path, boolean trimStartSeparator) clean Path path = path.replaceAll("[/\\\\]+", "/"); if (trimStartSeparator) { path = path.replaceFirst("^/+", ""); return path; |
String | cleanPath(String s) clean Path String retval = s.replace('\\', '_'); retval = retval.replace(':', '_'); retval = retval.replace('/', '_'); return retval; |
String | cleanPath(String sText, boolean isWindows) Clean path if not correct for the platform if (sText == null || sText.equals("")) return ""; if (sText.startsWith("http://") || sText.startsWith("https://")) return sText; String sFS = System.getProperty("file.separator"); if (isWindows) { sText = replace(sText, '/', sFS); } else { ... |
String | cleanPathSegment(final String toClean) Removes characters that aren't acceptable in a file path (mostly for windows). final String cleaned = toClean.replaceAll("[.\\\\/:*?\"<>|\\[\\]\\(\\)]", ""); if (cleaned.length() == 0) throw new IllegalStateException( "Path segment " + toClean + " has not valid characters and is thus empty"); return cleaned; |
String | filePathReplaceAll(String value) file Path Replace All String returnValue = value; if (returnValue == null || returnValue.trim().equals("")) { return ""; returnValue = returnValue.replaceAll("/", ""); returnValue = returnValue.replaceAll("\\", ""); returnValue = returnValue.replaceAll("\\.\\.", ""); returnValue = returnValue.replaceAll("&", ""); ... |
String | filePathTail(String filePath) returns the component of the url after the last / OR \ String t = tail(filePath, "/"); t = tail(t, "\\"); return t; |