Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Use java.io.Console?

Just a quick one here.

What are the benefits of using java.io.Console as opposed to using a BufferedReader wrapping an InputStreamReader for System.in?

Why would I use it?

Thanks for any advice!

like image 840
Humphrey Bogart Avatar asked Jun 09 '09 22:06

Humphrey Bogart


People also ask

What is meant by console in java?

What is Java Console? Java Console is a simple debugging aid that redirects any System. out and System. err to the console window. It is available for applets running with Java Plug-in and applications running with Java Web Start.

What is console class what is its use in java?

Console class provides methods to access the character-based console device, if any, associated with the current Java virtual machine. The Console class was added to java.io by JDK 6. Important Points: It is used to read from and write to the console, if one exists.

Why do we write java IO?

Java I/O (Input and Output) is used to process the input and produce the output. Java uses the concept of a stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. We can perform file handling in Java by Java I/O API.

What is writing console output in java?

Writing Console Output in Java refers to writing the output of a Java program to the console or any particular file. The methods used for streaming output are defined in the PrintStream class. The methods used for writing console output are print(), println() and write().


1 Answers

Because it's code that is already written for you...no need to re-invent the wheel. Chances are, you're not going to get it any better than it already is.

like image 74
Justin Niessner Avatar answered Oct 29 '22 21:10

Justin Niessner