List of utility methods to do File Name Clean
String | cleanFileName(String s) Make a string safely usable as a file name by removing all illegal characters (and a few more). return s.replaceAll("[^a-zA-Z0-9\\._]+", "_"); |
String | cleanFileName(String sText) Clean illegal file name characters from the given text N.B. if (sText == null || sText.equals("")) return ""; sText = replace(sText, ' ', "_"); sText = replace(sText, '"', ""); sText = replace(sText, '\'', ""); sText = replace(sText, '\\', ""); sText = replace(sText, '/', ""); sText = replace(sText, '<', ""); ... |
String | cleanFilename(String typeName) Produce a clean filename given a resource typeName. StringBuffer fix = new StringBuffer(typeName); for (int i = 0; i < fix.length(); i++) { char c = fix.charAt(i); if (!Character.isLetterOrDigit(c)) { fix.setCharAt(i, '_'); return fix.toString(); ... |