Seems like a pretty simple problem, but I've been looking my ass of for it and can't find it.
I want to read 1 character from stdin and disable the user to type more than 1 char, like the C getch() method. I've tried the read and readChar methods of many Readers and InputStreams classes (e.g. BufferedReader, InputStreamReader, DataInputStream, InputStream) but they all permit the user to type in a String and return the first character of the String when the user hits the enter button. I want to have the char returned immediately after the user hits a key and disable the user from typing more.
i think you could do some stuff with "KeyEvent" wherein you could watch the keyevent happen and then exit from the console.... i have not done it...but you could try it..... Use a KeyListener and wait for a KeyEvent to occur.... Once it occurs, stop and do whatever you want.... iam sorry if the idea is stupid...... ALL THE BEST !!!
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad: