is English And Numeric String by checking letter ascii code - Android Internationalization

Android examples for Internationalization:English

Description

is English And Numeric String by checking letter ascii code

Demo Code

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer;

public class Main{

     public static boolean isEnglishAndNumeric(String string) {
         if (string == null || string.length() == 0) {
             return false;
         }/*from ww  w .  j ava 2s  .c om*/
         char[] chars = string.toCharArray();
         int size = chars.length;
         for (int j = 0; j < size; j++) {
             char letter = chars[j];
             if ((97 > letter || letter > 122)
                     && (65 > letter || letter > 90)
                     && (48 > letter || letter > 57)) {
                 return false;
             }
         }
         return true;
     }

}

Related Tutorials