简体   繁体   中英

how to get indication of special charater read from file in java

In java I am writing a code in which I am reading a text file using DataInputStream.read() method and I want to get indication if the character read from the file is other than a digit(0,1,2,...) or alphabet(a,b,c,...). Please help how I can do that?

try this:

char c = //read a char

if( c >= 'a' && c <= 'z'){
 //is a lower case alphabet
}
else if (c >= '0' && c <= '9'){
// is a number
}else{
  //is something else
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM