Return true if the string is alphanum - Android java.lang

Android examples for java.lang:String Convert

Description

Return true if the string is alphanum

Demo Code


public class Main{

    /**//from www.ja  v a  2 s  . c  om
     * Return true if the string is alphanum.
     * <code>{letter digit }</code>
     * 
     **/
    public static boolean isLetterNumeric(String s) {
        int i = 0, len = s.length();
        while (i < len
                && (Character.isLowerCase(s.charAt(i))
                        || Character.isUpperCase(s.charAt(i)) || Character
                            .isDigit(s.charAt(i)))) {
            i++;
        }
        return (i >= len);
    }

}

Related Tutorials