• Post Reply Bookmark Topic Watch Topic
  • New Topic

Press any key to exit....  RSS feed

 
Martin Richard
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How on earth do I do this With java... System.in.read() is not the answer since it waits on a newline to send the buffer. Basically what I need is a getch() but can't seem to find an equivalent.
[ March 30, 2005: Message edited by: Martin Richard ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would usually just say there really isn't one. Your user will have to hit the enter key.

But I think I saw someone post a workaround. It may have been non-standard or Linux only or something and I didn't copy it into my stash of tips & tricks.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only workaround that I know of is to create your own Console class and redirect System.out and System.in to that.... To me, that always seemed like a lot of extra work when all I needed to do was change my message from "press any key to continue" to "press ENTER to continue". Users don;t really mind (that is, if the users are using a Console-based application at all...)

Any that removes the "Where's the ANY key?" questions
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!