Reading in Java

I'm new to Java ... Is there a similar method for ReadKey () in C # to avoid closing the console application?

thanks

+7
java console
source share
2 answers

One way to do this:

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

there are definitely shorter ones, but I think it’s convenient because it can be easily expanded.

+6
source share

You can also use System.in.read() if you're ok, only the 'Enter' key is your exit key.

+12
source share

All Articles