In a pure Java application how can you read standard input one character at a time (raw, unbuffered)?
If the application has a GUI, it is possible to use a Component like java.awt.TextField to check each character as it is typed.
If the application is command-line based, the only portable way to read a single character from standard input through Java
is to call System.in.read(). However, this call will block until the user types the <return> key at the end of a line, at which point the whole line
is available for read().
YeahBy Anonymous on October 13, 2009, 10:00 pmi tried it..it worked..thanks a lot.. :)
Reply | Read entire comment
Try using this char ch =By Masroor on August 7, 2009, 1:32 amTry using this char ch = (char)System.in.read();
Reply | Read entire comment
how to read a single characterBy Anonymous on February 26, 2009, 4:56 amwhen i try char c= System.in.read() it gives an error int cannot be changet to char since the return type of System.in.read()is int and not char what to do with...
Reply | Read entire comment
View all comments