Bhaxy Bhaxy -3 years ago 76
Java Question

What's the best way to get console-input in Java?

Getting output with Java is pretty easy as you can make use of

and the like.

Input, on the other hand, seems a little different. Some people recommend java.util.Scanner while others recommend, and I'm sure there's plenty of other recommendations. The two methods above are most regularly-used.

Neither seem to present very nice options (in my opinion). So, is there any better way to get input from a console window in Java? And if there isn't, which should I choose?

Answer Source

I think, The scanner class is quite helpful. For example with BufferedReader, you have to read a line at a time and parse it for the values. But in the scanner you get integers with nextInt() method etc.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download