Is char a white space character in Java
Description
The following code shows how to is char a white space character.
Example
//from w w w. ja v a 2 s . c o m
public class Main {
public static boolean isWhitespace(char c) {
// Optimized case for ASCII
if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd)) {
return true;
}
if (c == 0x1680) {
return true;
}
if (c < 0x2000 || c == 0x2007) {
return false;
}
return c <= 0x200b || c == 0x2028 || c == 0x2029 || c == 0x3000;
}
}
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »