• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I'm shocked

what about producing a CR/LF or whatever after a certain time (millisecs)
?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic