• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Press any key to continue...

 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this has been discussed million times. I need read charcters from console not waiting for <cr>. System.in.read() waits for <cr>. I can't use java.io.Console yet since compatibility. Please remind me how to read keyboard.
 
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
It may have been discussed many times, but the answer is always very simple: you can't do it. Furthermore, java.io.Console doesn't help: it only provides line-buffered-non-echoed reads for reading passwords, not any kind of general console-handling.

There's a library called "JLine" out there that might do this; I'm not sure. It uses native code, as any solution would need to.
 
D Rog
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed I was under impression that java.io.Console solves the problem. It seems time to join Java net team to add the feature in 1.7.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you react to intput made before a CR by subclassing FilterInputStream (with the original System.in as the underlying stream) and using your subclass to manually flush the member "in"?
 
Ernest Friedman-Hill
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

Originally posted by Chris Treglio:
Could you react to intput made before a CR by subclassing FilterInputStream (with the original System.in as the underlying stream) and using your subclass to manually flush the member "in"?



No. System.in.read() won't return until Enter is pressed, no matter what.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic