0

we all know that to input a string we need to press enter in java. But how can one detect or check what is written on the console before the enter button is pressed? For example, I have typed "hello" on the console but not pressed enter, how can I print "hello" just by detecting what is written on the console?

Using java frame (swing) this is easy as you can detect what you've written in the testfield by tf.getText, same thing I want to do on the console. Please help

while(true){

    print(detect_console_string())

    wait(5000); // milliseconds
}

Please help with this

clubby789
  • 2,543
  • 4
  • 16
  • 32
  • Why do you need to read console input before submit? maybe that would help – Superhuman Oct 17 '19 at 23:56
  • 2
    Possible duplicate of [How to read a single char from the console in Java (as the user types it)?](https://stackoverflow.com/questions/1066318/how-to-read-a-single-char-from-the-console-in-java-as-the-user-types-it) – FailingCoder Oct 18 '19 at 00:27

0 Answers0