Java String Clean cleanStringForFilename(String originalString)

Here you can find the source of cleanStringForFilename(String originalString)

Description

clean String For Filename

License

Open Source License

Declaration

public static String cleanStringForFilename(String originalString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String cleanStringForFilename(String originalString) {
        String string = removeSpaces(originalString);
        string = removeParens(string);/*from   ww w  . j  av a2  s. com*/
        return string;
    }

    public static String removeSpaces(String originalString) {
        return removeChar(originalString, ' ');
    }

    public static String removeParens(String originalString) {
        String string = removeChar(originalString, '(');
        string = removeChar(string, ')');
        return string;
    }

    private static String removeChar(String originalString, char badChar) {
        String returnString = "";
        char[] array = originalString.toCharArray();
        for (int i = 0; i < array.length; i++) {
            char currentChar = array[i];
            if (currentChar != ' ') {
                returnString += currentChar;
            }
        }
        return returnString;
    }
}

Related

  1. cleanString(String statement)
  2. cleanString(String unallowableCharacters, String stringToClean)
  3. cleanStringArrayChar(String value)
  4. cleanStringByLikeWithHSQL(String input)
  5. cleanStringCamelCase(String in)
  6. cleanStringForFilePath(final String dirty)
  7. cleanStringForJavaName(String original)
  8. cleanStringFromWhitespaces(String text)
  9. cleanText(final String input)