I am receiving a character array where it has valid and invalid characters. I need to only retrieve the characters that are valid. How can I do this ?
char[]ch = str.toCharacterArray();
for(int i=0;i<ch.length.i++){
if(!Character.isLetter(ch[i]))
system.out.println("not valid");
else
system.out.println("valid");
}
I don't think the above code works because I get invalid for all the valid and invalid characters in the character array.
by meaning characters I am expecting all alphanumeric and special characters
Note: I am getting values from the server, therefore the character array contains valid and invalid characters.