I need a method that can tell me if a String has non alphanumeric characters.
For example if the String is \"abcdef?\" or \"abcdefà\", the method must return true.>
One approach is to do that using the String class itself. Let's say that your string is something like that:
String s = "some text";
boolean hasNonAlpha = s.matches("^.*[^a-zA-Z0-9 ].*$");
one other is to use an external library, such as Apache commons:
String s = "some text";
boolean hasNonAlpha = !StringUtils.isAlphanumeric(s);