I would like to get input from the console character from character.
So for example, there's a String "input". If the current user input is "W", input is "W", as the user continues type in "h", input is "Wh" and continues "a" input is "a".
I used system.console() to accept the inputs but in eclipse it always return null.
Is there any way to fix it or there's another way to handle the character by character read from input?
Thanks!
There is something you need to watch out for : The System.console() method can return null. According to the API:
If the virtual machine is started from an interactive command line without
redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console.
Try to run your application from a console/terminal/cmd.