Java Utililty Methods File Name Clean

List of utility methods to do File Name Clean

Description

The list of methods to do File Name Clean are organized into topic(s).

Method

StringcleanFileName(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\\._]+", "_");
StringcleanFileName(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, '<', "");
...
StringcleanFilename(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();
...