Check whether the character is ASCII 7 bit control in Java
Description
The following code shows how to check whether the character is ASCII 7 bit control.
Example
//w w w.j av a 2s. c o m
public class Main {
public static boolean isAsciiControl(char ch) {
return ch < 32 || ch == 127;
}
public static void main(String[] argv){
System.out.println(isAsciiControl('a'));
System.out.println(isAsciiControl('A'));
System.out.println(isAsciiControl('3'));
System.out.println(isAsciiControl('-'));
System.out.println(isAsciiControl('\n'));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »