0% found this document useful (0 votes)
61 views

Reading Data From Keyboard: Inputstreamreader Class

There are several ways to read input from the keyboard in Java, including InputStreamReader, Console, Scanner, and DataInputStream. InputStreamReader connects to the keyboard input stream and converts bytes to characters, while BufferedReader can read line by line using readLine(). The Console class also provides a way to read text and passwords from the console without displaying passwords.

Uploaded by

Gagan Bansal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Reading Data From Keyboard: Inputstreamreader Class

There are several ways to read input from the keyboard in Java, including InputStreamReader, Console, Scanner, and DataInputStream. InputStreamReader connects to the keyboard input stream and converts bytes to characters, while BufferedReader can read line by line using readLine(). The Console class also provides a way to read text and passwords from the console without displaying passwords.

Uploaded by

Gagan Bansal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Reading data from keyboard

There are many ways to read data from the keyboard. For example:

 InputStreamReader
 Console
 Scanner
 DataInputStream etc.

InputStreamReader class

InputStreamReader class can be used to read data from keyboard.It performs two tasks:

 connects to input stream of keyboard


 converts the byte-oriented stream into character-oriented stream

BufferedReader class

BufferedReader class can be used to read data line by line by readLine() method.

Java Console Class


The Java Console class is be used to get input from console. It provides methods to read texts
and passwords.

If you read password using Console class, it will not be displayed to the user.

The java.io.Console class is attached with system console internally. The Console class is
introduced since 1.5.
 String text=System.console().readLine();
 System.out.println("Text is: "+text);

You might also like