Read user input char value from console in Java
Description
The following code shows how to read user input char value from console.
Example
/*ww w.j a v a 2s . c om*/
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
char c = (char) System.in.read();
while (c != '\r') {
System.out.println(c);
c = (char) System.in.read();
}
} catch (IOException e) {
}
}
}