Last active
April 14, 2023 10:39
-
-
Save jarek-przygodzki/0271ba7bae239cf0b5a61e1ba6741a44 to your computer and use it in GitHub Desktop.
Wait for enter key pressed in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Be beware http://stackoverflow.com/questions/4203646/system-console-returns-null | |
*/ | |
public static void waitForEnter(String message, Object... args) { | |
Console c = System.console(); | |
if (c != null) { | |
// printf-like arguments | |
if (message != null) | |
c.format(message, args); | |
c.format("\nPress ENTER to proceed.\n"); | |
c.readLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment