This function
checks for the special characters in a string to make the passed
string as a valid file name the special characters checked are
~`!@#$%^&*()+=<>?:\"{}|,/;'[]\
public static String makeValidFileName(String fileName) { int strLength = fileName.length(); char[] charArray = new char[strLength]; fileName.getChars(0, strLength, charArray, 0); //Convert the passed string into the array of chars StringBuffer newString = new StringBuffer(); for (int i = 0; i < strLength; ++i) { //if the current char of the passed string contains the special char then dont add it to the string buffer //else add it to the string buffer if (! (specialCharacters.indexOf(charArray[i], 0) > 0)) { newString.append(charArray[i]); } } return newString.toString(); }