public static boolean isAlphaNumericOrContainsOnlyCharacters ( String in , String chars ) { char c = 0 ; for ( int i = 0 ; i < in . length ( ) ; i ++ ) { c = in . charAt ( i ) ; if ( Character . isLetterOrDigit ( c ) == ( chars . indexOf ( c ) != - 1 ) ) { return false ; } } return true ; }
tells whether all characters in a String are letters or digits or part of a given String