How do I read input from the user (or send output) analogous to using standard input and standard output in C or C++?
Ans : Use the standard system streams: System.in, System.out, and System.err. C and C++ define standard input/output libraries (collections of compiled functions) that rely heavily on three input/output streams, called standard input, standard output, and standard error. The analogue in Java to a library in C or C++ is a Java language package. Completing the analogy, the java.io package defines essentially the same three streams, which you access as fields of the System class: • System.in: standard input; the customary input stream for keyboard input when a program lacks a graphical user interface (GUI). • System.out: standard output; the customary output stream for programs that lack a GUI. • System.err: standard error; the customary output stream for error output in programs that lack a GUI. System.in is an instance of InputStream and System.out and System.err are instances of class PrintStream. If you want just string output (to either System.out or System.err), the PrintStream meth
Related Questions
- I want to set a users password using the Unix passwd command, but how do I script that? It doesn read standard input!
- How do I read input from the user (or send output) analogous to using standard input and standard output in C or C++?
- What input and output options are available on the standard dpsReality board set?