- Joined
- Mar 13, 2005
- Location
- Austin, Texas
I'm writing an application and I need to be able to pause execution while the program waits for the user to press ENTER.
(Press Enter to Continue...)
Right now I'm using a crutch- I wait for the user to press the letter C.
It would be wonderful if there was a Java equivalent to the getch() function from C.
(Press Enter to Continue...)
Right now I'm using a crutch- I wait for the user to press the letter C.
Code:
public void waitForCont()
{
out.printf("\nPress C to Continue...\n");
boolean pressed = false;
String entered = "";
while(!pressed)
{
entered=kb.next();
if((entered.equals("C"))||entered.equals("c"))
pressed=true;
}
}
It would be wonderful if there was a Java equivalent to the getch() function from C.