List of utility methods to do File Name Sanitize
String | sanitize(String fileName) sanitize StringBuffer buffer = new StringBuffer(); for (char c : fileName.toCharArray()) { if (Character.isJavaIdentifierPart(c)) { buffer.append(c); if (buffer.length() == 0) { buffer.append(System.currentTimeMillis()); ... |
String | sanitizeBlankNodeName(String filename) Blank node names should start with a letter and have only letters/numbers. StringBuffer ret = new StringBuffer(filename.length()); if (!filename.isEmpty()) { char charAt0 = filename.charAt(0); if (Character.isLetter(charAt0)) ret.append(charAt0); for (int i = 1; i < filename.length(); i++) { char ch = filename.charAt(i); ... |
String | sanitizeFilename(String filename) sanitize Filename return filename.replaceAll("[^a-zA-Z0-9.-]", "_"); |
String | sanitizeFileName(String filename) Given an input, return a sanitized form of the input suitable for use as a file/directory name return sanitizeFileName(filename, SANITIZED_CHAR);
|
String | sanitizeFileName(String filename) sanitize File Name if (filename == null) return null; if (filename.contains("/")) { filename = filename.replace("/", "_"); if (filename.contains(":")) { filename = filename.replace(":", "_"); if (filename.contains("*")) { filename = filename.replace("*", "_"); if (filename.contains("?")) { filename = filename.replace("?", "_"); if (filename.contains("\"")) { filename = filename.replace("\"", "_"); if (filename.contains("<")) { filename = filename.replace("<", "_"); if (filename.contains(">")) { filename = filename.replace(">", "_"); if (filename.contains("|")) { filename = filename.replace("|", "_"); if (filename.contains("\\")) { filename = filename.replace("\\", "_"); if (filename.contains("&")) filename = filename.replace("&", "_"); return filename; |
String | sanitizeFilename(String fileName) sanitize Filename if (fileName == null) { return null; return fileName.replaceAll("/", ".").replaceAll("[\\[|\\]]", " ").replaceAll(" ", ""); |
String | sanitizeFilename(String name) Substitute any characters to be avoided in a file name with '_'. if (name.isEmpty()) throw new IllegalArgumentException("Empty file name!"); return name.replaceAll("[\\W&&[^.-]]", "_"); |
String | sanitizeFileName(String name) sanitize File Name String result = ""; if (name == null) return result; for (int k = 0; k < name.length(); k++) { char c = name.charAt(k); if (Character.isLetterOrDigit(c)) result += c; else ... |
String | sanitizeFilename(String name) Replace forbidden characters with "_" in a filename. return name.replaceAll("[:\\\\/*?|<>]", "_"); |
String | sanitizeFileName(String name) Sanitizes the name as a valid fat32 filename. StringBuffer buffer = new StringBuffer(name.length()); for (int i = 0; i < name.length(); i++) { int codePoint = name.codePointAt(i); char character = name.charAt(i); if (Character.isLetterOrDigit(character) || isSpecialFat32(character)) { buffer.appendCodePoint(codePoint); } else { buffer.append("_"); ... |