开发者

Readkey in Java

开发者 https://www.devze.com 2022-12-24 05:00 出处:网络
I am new to Java ... is there a simila开发者_如何学运维r method to the ReadKey() in C# to avoid that a console application closes?

I am new to Java ... is there a simila开发者_如何学运维r method to the ReadKey() in C# to avoid that a console application closes?

thanks


YOu can also use System.in.read(), if you are ok with just 'Enter' key being your exit key.


One way to do it:

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.readLine();

there are definitely shorter ones, but I think this one's convenient, because it can easily be extended.

0

精彩评论

暂无评论...
验证码 换一张
取 消