I am new to Java and today I was trying to read some data from the console using a BufferedReader object. I am reading input inside a while loop and terminating the loop as soon as the user (me) types the exit key, say 'q'. The problem is that, I am not able to type in characters when the program is run, thus my program ends up in an infinite loop. I think my code has no bugs, but still posting it here, may be I am wrong.
public static void main(String args[]) throws IOException
{
char c;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
do
{
c = (char) br.read();
System.out.println(c);
} while(c != 'q');
}
So, is there something that my IDE does not support (like console input) or my code is buggy or something else is causing the infinite loop?