Simple Input/Output

Input is the data entered by the user. Output is any information that a program conveys to the user. Java provides a class System that has three important fields in, out and err which help the user to give the input, take the output and display an error respectively. InputStream and PrintStream are a part of Java IO streams and contained in java.io.package. A string can be printed using print() and println() methods of PrintStream class. The println() terminates the current line by writing a line separator at the end of the string, while the print() method only displays the string.

System.in.read() reads one character from the keyboard and returns the equivalent ASCII value. Two main Java stream classes are InputStream and OutputStream. InputStream is an abstract class, which is the super class of all classes representing an input stream. OutputStream is an abstract class, which is the super class of all classes representing an output stream. The class System provides access to three streams: System.in, System.out and System.err. The two types of Java streams are CharacterOriented Stream and ByteOriented Stream. The CharacterOriented reads input in character form. The ByteOriented Stream reads input in binary form. Java IO classes used to receive input from the user are Java.io.InputStream, Java.io.InputStreamReader and Java.io.BufferedReader. Java InputStreamReader class translates data bytes received from an InputStream into a stream of characters. Java BufferedReader class buffers the input data received from InputStreamReader. Java provides a wrapper class for each primitive data type. All wrapper classes contain static methods for changing the string data into primitive data type.

To Access the full content, Please Purchase