• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading from stdIn without "new line" "cr" "enter"

 
Javoso Torso
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello There,

I am tired of searching, prob. searching the wrong way but anyway

I am trying to read from the standard imput, the keyboard.

My problem is that the user does not press "enter", as soon as he press a key I would like to get it: printed out, whatever...

All what I could find yet was always quited by an "enter"...

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't do it, sorry. Java's stdin is line-buffered.

The best you can do is put up a GUI window with a GUI-based terminal in it (which you'd have to write, or obtain from a third party.) GUI windows get notified of each individual keystroke.

Or you could use native (i.e., non-Java, non-portable) code.
 
Javoso Torso
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm shocked

what about producing a CR/LF or whatever after a certain time (millisecs)
?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Javoso Torso:

I'm shocked


Why? Java was designed to be cross-platform. Many platforms, like appliances, phones, Java Cards and the like, don't have consoles at all. Not to mention that character user interfaces are going the way of the buggy whip. If you want a GUI, use AWT, Swing or SWT. If you REALLY want a character user interface, use a language that has the features you need (the right tool for the job and so on).
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!