Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes another question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "another question" Watch "another question" New topic

another question

Adam Jones

Joined: Aug 22, 2002
Posts: 19
ok, i need to add a Press any Key to Continue to my program....i know i can do a
to get input and then use a Unicode value and get the semi-desired results, but i want the user to be able to hit any key at all just like it says... easy way out there>?
thanks in advance
adam jones
Paul LaBrier

Joined: Apr 08, 2002
Posts: 21
I needed the same thing for a console app I was writing for a class.
What I settled on was:

It worked ok. The user could type until their fingers fell off and nothings happened until they pressed enter.
Paul LaBrier
Adam Jones

Joined: Aug 22, 2002
Posts: 19
thanks for the reply, but what i was looking for was a press any key...i used the unicode value for enter "2324 and then just did a readLine() and it gave me the same results, but that is not what the prof wants i mean it worked just fine by me, but you know how professors are
is there just a way to pause and wait for any response at all from the keyboard?
i am very sure there has to be, but how would that be done?
thanks again for your input
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
Does anyone know how to do this in java? In C/C++ it is possible to do it with getchar(). InputStream's read()method blocks until the user types the <return> key at the end of a line, at which point the whole line is available for read().

Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
I agree. Here's the link:
subject: another question
It's not a secret anymore!