code and normally a machine screen is utilized to standard
output stream and
referred to as System.out.
Standard Input: This is utilized to encourage the information to client’s code and
normally a console is utilized as standard data stream and referred to as System.in.
Sample Implementation:
import java.io.*;
public class Myreadconsole {
public static void main(string args[]) throws IOException {
InputStreamReader cinx = invalid;
try {
cinx = new InputStreamReader(system.in);
System.out.println(“Input string, press “e” to exit.”);
char charx;
do {
charx = (char) cinx.read();
System.out.print(charx);
} while(charx != ‘e’);
}
finally {
if (cinx != invalid) {
cinx.close();
}
}
}
The code mentioned above must be saved in a file named Myreadconsole.java. Upon
compilation
and execution of this code, the system must be able to receive and interpret
characters.
Do'stlaringiz bilan baham: