I have a console application that, after completing its tasks, should give feedback to the user, for example, “operation completed” or “operation failed” and a detailed error.
The fact is that if I just “let it work,” the output message will be printed, but the console will close soon, leaving no time to read the message.
As far as I remember, in C ++, each console application ends with pressing any key to exit or something like that. In C #, I can model this behavior with
Console.ReadKey();
But how can I do this in Java? I use the Scanner class, but considering that the “input” is my Scanner instance:
input.next() System.exit(0);
Any key will work except return, which is very important here. Any pointers?
java console-application
makoshichi May 17 '11 at 14:13 2011-05-17 14:13
source share